Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
events: Avoid unnecessary sorted() in peer_remove.
Tim Abbottf9f44c8a52ce
diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex c8160edcaa3..ba9cf00a05e 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -1736,6 +1736,7 @@ def apply_event("subscribers" if "subscribers" in sub else "partial_subscribers")subscribers = set(sub[subscriber_key]) | user_ids+ # Keep this sorted by user ID; peer_remove relies on it.sub[subscriber_key] = sorted(subscribers)elif event["op"] == "peer_remove":# Note: We don't update subscriber_count here, as with peer_add.@@ -1753,8 +1754,10 @@ def apply_event(subscriber_key = ("subscribers" if "subscribers" in sub else "partial_subscribers")- subscribers = set(sub[subscriber_key]) - user_ids- sub[subscriber_key] = sorted(subscribers)+ # Subscriber lists are sorted, so filtering preserves that.+ sub[subscriber_key] = [+ uid for uid in sub[subscriber_key] if uid not in user_ids+ ]else:raise AssertionError("Unexpected event type {type}/{op}".format(**event))elif event["type"] == "presence":diff --git a/zerver/lib/subscription_info.py b/zerver/lib/subscription_info.pyindex 30ee6d6051a..b01b1fe9e74 100644--- a/zerver/lib/subscription_info.py+++ b/zerver/lib/subscription_info.py@@ -630,6 +630,8 @@ def bulk_get_subscriber_user_ids(One optimization is to use two branches for creating this query,to avoid joining on zerver_userprofile when we're not sendingpartial users.++ Both branches must keep the ORDER BY; apply_event relies on it."""if partial_fetch_recipient_ids: