mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Use the presence cachemap ordering to early-abort the iteration loop
This commit is contained in:
parent
f683b5de47
commit
45543028bb
@ -875,10 +875,15 @@ class PresenceEventSource(object):
|
|||||||
|
|
||||||
updates = []
|
updates = []
|
||||||
# TODO(paul): use a DeferredList ? How to limit concurrency.
|
# TODO(paul): use a DeferredList ? How to limit concurrency.
|
||||||
for observed_user in cachemap.keys():
|
for observed_user in reversed(cachemap.keys()):
|
||||||
cached = cachemap[observed_user]
|
cached = cachemap[observed_user]
|
||||||
|
|
||||||
if cached.serial <= from_key or cached.serial > max_serial:
|
# Since this is ordered in descending order of serial, we can just
|
||||||
|
# stop once we've seen enough
|
||||||
|
if cached.serial <= from_key:
|
||||||
|
break
|
||||||
|
|
||||||
|
if cached.serial > max_serial:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not (yield self.is_visible(observer_user, observed_user)):
|
if not (yield self.is_visible(observer_user, observed_user)):
|
||||||
|
Loading…
Reference in New Issue
Block a user