1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

traffic: improve add_short_packet by avoiding str.split

Avoid str.split, which will repeat for each packet.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Joe Guo 2018-05-10 17:04:50 +12:00 committed by Andrew Bartlett
parent 5107e56aa0
commit c1af6a0dad

View File

@ -794,12 +794,12 @@ class Conversation(object):
if p.is_really_a_packet():
self.packets.append(p)
def add_short_packet(self, timestamp, p, extra, client=True):
def add_short_packet(self, timestamp, protocol, opcode, extra,
client=True):
"""Create a packet from a timestamp, and 'protocol:opcode' pair, and a
(possibly empty) list of extra data. If client is True, assume
this packet is from the client to the server.
"""
protocol, opcode = p.split(':', 1)
src, dest = self.guess_client_server()
if not client:
src, dest = dest, src
@ -1220,7 +1220,7 @@ class TrafficModel(object):
timestamp += wait
if hard_stop is not None and timestamp > hard_stop:
break
c.add_short_packet(timestamp, p, extra)
c.add_short_packet(timestamp, protocol, opcode, extra)
key = key[1:] + (p,)