mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-13 17:42:42 +08:00
PERF: Remove in operator from inner loop.
Ask forgiveness via exception handling instead.
This commit is contained in:
@@ -217,8 +217,10 @@ class AlgorithmSimulator(object):
|
||||
Update the universe with new event information.
|
||||
"""
|
||||
# Update our knowledge of this event's sid
|
||||
if event.sid in self.current_data:
|
||||
# rather than use if event.sid in ..., just trying
|
||||
# and handling the exception is significantly faster
|
||||
try:
|
||||
sid_data = self.current_data[event.sid]
|
||||
else:
|
||||
except KeyError:
|
||||
sid_data = self.current_data[event.sid] = SIDData()
|
||||
sid_data.__dict__.update(event.__dict__)
|
||||
|
||||
Reference in New Issue
Block a user