mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 09:35:45 +03:00
Create singletons for StateFilter.{all,none}()
(#11836)
No point recreating these for each call, since they are frozen
This commit is contained in:
parent
fd65139714
commit
57e4786e90
2 changed files with 10 additions and 5 deletions
1
changelog.d/11836.misc
Normal file
1
changelog.d/11836.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Minor performance improvement in room state lookup.
|
|
@ -74,21 +74,21 @@ class StateFilter:
|
|||
|
||||
@staticmethod
|
||||
def all() -> "StateFilter":
|
||||
"""Creates a filter that fetches everything.
|
||||
"""Returns a filter that fetches everything.
|
||||
|
||||
Returns:
|
||||
The new state filter.
|
||||
The state filter.
|
||||
"""
|
||||
return StateFilter(types=frozendict(), include_others=True)
|
||||
return _ALL_STATE_FILTER
|
||||
|
||||
@staticmethod
|
||||
def none() -> "StateFilter":
|
||||
"""Creates a filter that fetches nothing.
|
||||
"""Returns a filter that fetches nothing.
|
||||
|
||||
Returns:
|
||||
The new state filter.
|
||||
"""
|
||||
return StateFilter(types=frozendict(), include_others=False)
|
||||
return _NONE_STATE_FILTER
|
||||
|
||||
@staticmethod
|
||||
def from_types(types: Iterable[Tuple[str, Optional[str]]]) -> "StateFilter":
|
||||
|
@ -527,6 +527,10 @@ class StateFilter:
|
|||
)
|
||||
|
||||
|
||||
_ALL_STATE_FILTER = StateFilter(types=frozendict(), include_others=True)
|
||||
_NONE_STATE_FILTER = StateFilter(types=frozendict(), include_others=False)
|
||||
|
||||
|
||||
class StateGroupStorage:
|
||||
"""High level interface to fetching state for event."""
|
||||
|
||||
|
|
Loading…
Reference in a new issue