Add fastpath optimisation

This commit is contained in:
David Baker 2017-10-05 13:20:22 +01:00
parent e433393c4f
commit ed80c6b6cc

View file

@ -112,6 +112,12 @@ class BulkPushRuleEvaluator(object):
@defer.inlineCallbacks
def _get_sender_power_level(self, event, context):
pl_event_key = (EventTypes.PowerLevels, "", )
if pl_event_key in context.prev_state_ids:
# fastpath: if there's a power level event, that's all we need, and
# not having a power level event is an extreme edge case
auth_events_ids = [context.prev_state_ids[pl_event_key]]
else:
auth_events_ids = yield self.auth.compute_auth_events(
event, context.prev_state_ids, for_verification=False,
)