summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2018-05-10 17:01:19 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-05-12 02:09:29 +0200
commit5107e56aa089b51f8d00049b63b2c79ea9e495cc (patch)
treece3e72b1fb00401c9221e4eab640a0a670772ab3 /python
parent4fb5e28b663c57cc4f67b28312a291132dae2fb6 (diff)
downloadsamba-5107e56aa089b51f8d00049b63b2c79ea9e495cc.tar.gz
samba-5107e56aa089b51f8d00049b63b2c79ea9e495cc.tar.bz2
samba-5107e56aa089b51f8d00049b63b2c79ea9e495cc.zip
traffic: simplify forget_packets_outside_window
Make code compact, and improve performance a little bit. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/emulate/traffic.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py
index d65aec6f32c..95ab3c9d380 100644
--- a/python/samba/emulate/traffic.py
+++ b/python/samba/emulate/traffic.py
@@ -948,18 +948,8 @@ class Conversation(object):
:param s: start of the window
:param e: end of the window
"""
-
- new_packets = []
- for p in self.packets:
- if p.timestamp < s or p.timestamp > e:
- continue
- new_packets.append(p)
-
- self.packets = new_packets
- if new_packets:
- self.start_time = new_packets[0].timestamp
- else:
- self.start_time = None
+ self.packets = [p for p in self.packets if s <= p.timestamp <= e]
+ self.start_time = self.packets[0].timestamp if self.packets else None
def renormalise_times(self, start_time):
"""Adjust the packet start times relative to the new start time."""