Skip to content

Commit

Permalink
Cache SettingInstance hash for faster indexing
Browse files Browse the repository at this point in the history
CURA-11050
  • Loading branch information
wawanbreton committed Sep 29, 2023
1 parent c869bc4 commit 7043dbf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion UM/Settings/SettingRelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def __init__(self, owner: SettingDefinition, target: SettingDefinition, relation
def __hash__(self) -> int:
"""Ensure that the SettingRelation is hashable, so it can be used in a set."""

return hash((self._owner, self._target, self._type, self._role))
try:
return self._hash
except AttributeError:
self._hash = hash((self._owner, self._target, self._type, self._role))
return self._hash

@property
def owner(self) -> SettingDefinition:
Expand Down

0 comments on commit 7043dbf

Please sign in to comment.