From 43f1c72511e3f68172ea16f742506693b8feff4c Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 1 Aug 2011 11:17:01 +1200 Subject: Refactor the way we calculate views of the flow list. The naive approach we used before recalculated the view on every access, and consequently had serious performance problems. --- libmproxy/console.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'libmproxy/console.py') diff --git a/libmproxy/console.py b/libmproxy/console.py index 6fd8c2ca..6a0c9125 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -208,7 +208,7 @@ class ConnectionItem(WWrap): class ConnectionListView(urwid.ListWalker): def __init__(self, master, state): self.master, self.state = master, state - if self.state.flow_list: + if self.state.flow_count(): self.set_focus(0) def get_focus(self): @@ -709,7 +709,7 @@ class StatusBar(WWrap): self.message("") t = [ - ('statusbar_text', ("[%s]"%len(self.master.state.flow_list)).ljust(7)), + ('statusbar_text', ("[%s]"%self.master.state.flow_count()).ljust(7)), ] t.extend(self.get_status()) @@ -1657,8 +1657,7 @@ class ConsoleMaster(flow.FlowMaster): self.refresh_server_playback = not self.refresh_server_playback def shutdown(self): - for i in self.state.flow_list: - i.kill(self) + self.state.killall(self) controller.Master.shutdown(self) def sync_list_view(self): @@ -1681,7 +1680,7 @@ class ConsoleMaster(flow.FlowMaster): self.statusbar.refresh_connection(c) def process_flow(self, f, r): - if f.match(self.state.intercept) and not f.request.is_replay(): + if self.state.intercept and f.match(self.state.intercept) and not f.request.is_replay(): f.intercept() else: r.ack() -- cgit v1.2.3