Commit 753683e3 authored by Malthe Borch's avatar Malthe Borch

Optimize 'OFS.ObjectManager.__contains__' method

Backported from master.
parent 561a1f4c
...@@ -8,7 +8,9 @@ http://docs.zope.org/zope2/ ...@@ -8,7 +8,9 @@ http://docs.zope.org/zope2/
2.13.25 (unreleased) 2.13.25 (unreleased)
-------------------- --------------------
- TBD - Optimized the `OFS.ObjectManager.__contains__` method to do the
least amount of work necessary.
2.13.24 (2016-02-29) 2.13.24 (2016-02-29)
-------------------- --------------------
......
...@@ -787,7 +787,11 @@ class ObjectManager(CopyContainer, ...@@ -787,7 +787,11 @@ class ObjectManager(CopyContainer,
return self._setObject(key, value) return self._setObject(key, value)
def __contains__(self, name): def __contains__(self, name):
return name in self.objectIds() for ob in self._objects:
if name == ob['id']:
return True
return False
def __iter__(self): def __iter__(self):
return iter(self.objectIds()) return iter(self.objectIds())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment