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

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>
This commit is contained in:
Joe Guo 2018-05-10 17:01:19 +12:00 committed by Andrew Bartlett
parent 4fb5e28b66
commit 5107e56aa0

View File

@ -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."""