diff options
author | Erik Johnston <erik@matrix.org> | 2019-02-15 10:17:43 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-02-15 10:20:02 +0000 |
commit | 02c729d6b0f6b8f41455737cde0b8aeb39782a7e (patch) | |
tree | 77eb970d59d68cfca96a5a66ac33eb54912b9076 /synapse/config/room_directory.py | |
parent | Fixup comments (diff) | |
download | synapse-02c729d6b0f6b8f41455737cde0b8aeb39782a7e.tar.xz |
Hoist up checks to reduce overall work
Diffstat (limited to 'synapse/config/room_directory.py')
-rw-r--r-- | synapse/config/room_directory.py | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/synapse/config/room_directory.py b/synapse/config/room_directory.py index 6815d6e9b7..aa113f0edf 100644 --- a/synapse/config/room_directory.py +++ b/synapse/config/room_directory.py @@ -177,24 +177,22 @@ class _RoomDirectoryRule(object): if not self._user_id_regex.match(user_id): return False - # If we are not given any aliases then this rule only matches if the - # alias glob matches all aliases - matched = False - if not aliases: - if not self._alias_matches_all: - return False - else: - # Otherwise, we just need one alias to match - matched = False - for alias in aliases: - if self._alias_regex.match(alias): - matched = True - break + if not self._room_id_regex.match(room_id): + return False - if not matched: - return False + # We only have alias checks left, so we can short circuit if the alias + # rule matches everything. + if self._alias_matches_all: + return True - if not self._room_id_regex.match(room_id): + # If we are not given any aliases then this rule only matches if the + # alias glob matches all aliases, which we checked above. + if not aliases: return False - return True + # Otherwise, we just need one alias to match + for alias in aliases: + if self._alias_regex.match(alias): + return True + + return False |