diff options
| author | Joe Guo <joeg@catalyst.net.nz> | 2018-05-10 17:23:02 +1200 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2018-05-14 05:38:06 +0200 |
| commit | d444221d67abc05dc9966dd7e0a37d30f9848953 (patch) | |
| tree | 37f0c6fdd6149229732ae18750588fad60512b41 /python | |
| parent | 21c82072ab87e3dee617b3219364e55e9c106432 (diff) | |
| download | samba-d444221d67abc05dc9966dd7e0a37d30f9848953.tar.gz samba-d444221d67abc05dc9966dd7e0a37d30f9848953.tar.bz2 samba-d444221d67abc05dc9966dd7e0a37d30f9848953.zip | |
traffic: improve add_short_packet by avoiding dict.get
dict.get is slower than [].
Avoid get to improve performance.
(For 3989418 calls, total time decease from 9.395 to 8.573)
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon May 14 05:38:06 CEST 2018 on sn-devel-144
Diffstat (limited to 'python')
| -rw-r--r-- | python/samba/emulate/traffic.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index 227477a5425..db0fcf7788b 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -811,9 +811,12 @@ class Conversation(object): src, dest = self.guess_client_server() if not client: src, dest = dest, src - - desc = OP_DESCRIPTIONS.get((protocol, opcode), '') - ip_protocol = IP_PROTOCOLS.get(protocol, '06') + key = (protocol, opcode) + desc = OP_DESCRIPTIONS[key] if key in OP_DESCRIPTIONS else '' + if protocol in IP_PROTOCOLS: + ip_protocol = IP_PROTOCOLS[protocol] + else: + ip_protocol = '06' packet = Packet(timestamp - self.start_time, ip_protocol, '', src, dest, protocol, opcode, desc, extra) |
