mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Improve performance of loading flows from a file hugely.
Fell into the "expensive __eq__ method" trap. Oh, Python, you little scamp.
This commit is contained in:
parent
43f1c72511
commit
675b3133b4
@ -193,9 +193,6 @@ class Flow:
|
||||
f.load_state(state)
|
||||
return f
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.get_state() == other.get_state()
|
||||
|
||||
def script_serialize(self):
|
||||
data = self.get_state()
|
||||
return json.dumps(data)
|
||||
|
@ -170,18 +170,18 @@ class uFlow(libpry.AutoTree):
|
||||
f = tutils.tflow()
|
||||
f.response = tutils.tresp(f.request)
|
||||
state = f.get_state()
|
||||
assert f == flow.Flow.from_state(state)
|
||||
assert f.get_state() == flow.Flow.from_state(state).get_state()
|
||||
|
||||
f.response = None
|
||||
f.error = proxy.Error(f.request, "error")
|
||||
state = f.get_state()
|
||||
assert f == flow.Flow.from_state(state)
|
||||
assert f.get_state() == flow.Flow.from_state(state).get_state()
|
||||
|
||||
f2 = tutils.tflow()
|
||||
f2.error = proxy.Error(f.request, "e2")
|
||||
assert not f == f2
|
||||
f.load_state(f2.get_state())
|
||||
assert f == f2
|
||||
assert f.get_state() == f2.get_state()
|
||||
|
||||
def test_kill(self):
|
||||
s = flow.State()
|
||||
@ -410,7 +410,7 @@ class uSerialize(libpry.AutoTree):
|
||||
assert len(l) == 1
|
||||
|
||||
f2 = l[0]
|
||||
assert f2 == f
|
||||
assert f2.get_state() == f.get_state()
|
||||
assert f2.request.assemble() == f.request.assemble()
|
||||
|
||||
def test_load_flows(self):
|
||||
|
Loading…
Reference in New Issue
Block a user