mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
Removed calls to ifilterfalse.
Replaced calls to ifilterfalse by list comprehensions because ifilterfalse is not part of python 3. Also changed some lists to sets for faster lookup. Refer to #256.
This commit is contained in:
committed by
Tim Abbott
parent
851b0a871d
commit
176c507b0a
@@ -2534,7 +2534,7 @@ def apply_events(state, events, user_profile):
|
|||||||
if event['op'] == "add":
|
if event['op'] == "add":
|
||||||
state['realm_users'].append(person)
|
state['realm_users'].append(person)
|
||||||
elif event['op'] == "remove":
|
elif event['op'] == "remove":
|
||||||
state['realm_users'] = itertools.ifilterfalse(our_person, state['realm_users'])
|
state['realm_users'] = [x for x in state['realm_users'] if not our_person(x)]
|
||||||
elif event['op'] == 'update':
|
elif event['op'] == 'update':
|
||||||
for p in state['realm_users']:
|
for p in state['realm_users']:
|
||||||
if our_person(p):
|
if our_person(p):
|
||||||
@@ -2585,17 +2585,17 @@ def apply_events(state, events, user_profile):
|
|||||||
return sub['name'].lower()
|
return sub['name'].lower()
|
||||||
|
|
||||||
if event['op'] == "add":
|
if event['op'] == "add":
|
||||||
added_names = list(map(name, event["subscriptions"]))
|
added_names = set(map(name, event["subscriptions"]))
|
||||||
was_added = lambda s: name(s) in added_names
|
was_added = lambda s: name(s) in added_names
|
||||||
|
|
||||||
# add the new subscriptions
|
# add the new subscriptions
|
||||||
state['subscriptions'] += event['subscriptions']
|
state['subscriptions'] += event['subscriptions']
|
||||||
|
|
||||||
# remove them from unsubscribed if they had been there
|
# remove them from unsubscribed if they had been there
|
||||||
state['unsubscribed'] = list(itertools.ifilterfalse(was_added, state['unsubscribed']))
|
state['unsubscribed'] = [x for x in state['unsubscribed'] if not was_added(x)]
|
||||||
|
|
||||||
elif event['op'] == "remove":
|
elif event['op'] == "remove":
|
||||||
removed_names = list(map(name, event["subscriptions"]))
|
removed_names = set(map(name, event["subscriptions"]))
|
||||||
was_removed = lambda s: name(s) in removed_names
|
was_removed = lambda s: name(s) in removed_names
|
||||||
|
|
||||||
# Find the subs we are affecting.
|
# Find the subs we are affecting.
|
||||||
@@ -2610,7 +2610,7 @@ def apply_events(state, events, user_profile):
|
|||||||
state['unsubscribed'] += removed_subs
|
state['unsubscribed'] += removed_subs
|
||||||
|
|
||||||
# Now filter out the removed subscriptions from subscriptions.
|
# Now filter out the removed subscriptions from subscriptions.
|
||||||
state['subscriptions'] = list(itertools.ifilterfalse(was_removed, state['subscriptions']))
|
state['subscriptions'] = [x for x in state['subscriptions'] if not was_removed(x)]
|
||||||
|
|
||||||
elif event['op'] == 'update':
|
elif event['op'] == 'update':
|
||||||
for sub in state['subscriptions']:
|
for sub in state['subscriptions']:
|
||||||
|
|||||||
Reference in New Issue
Block a user