Skip to content

Commit

Permalink
apply_event: Replace list comprehension with list.remove.
Browse files Browse the repository at this point in the history
This should be about 4 times faster, saving something like half a
millisecond on each stream of 10000 subscribers.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk authored and timabbott committed Dec 31, 2019
1 parent bbafced commit 8f281c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zerver/lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def name(sub: Dict[str, Any]) -> str:
# Remove our user from the subscribers of the removed subscriptions.
if include_subscribers:
for sub in removed_subs:
sub['subscribers'] = [id for id in sub['subscribers'] if id != user_profile.id]
sub['subscribers'].remove(user_profile.id)

# We must effectively copy the removed subscriptions from subscriptions to
# unsubscribe, since we only have the name in our data structure.
Expand Down

0 comments on commit 8f281c4

Please sign in to comment.