1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-20 22:50:26 +03:00

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
This commit is contained in:
Joe Guo 2018-05-10 17:23:02 +12:00 committed by Andrew Bartlett
parent 21c82072ab
commit d444221d67

View File

@ -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)