summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-04-11 11:25:08 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-04-11 11:25:08 +0200
commit74f2b4105b32fe719c4ce7ba3ad86f1abe54ed3b (patch)
tree94a2a7576299bad01fa7475e76ddf3406e6598f7
parentbbfa8f4f91766a17d03d10ba7f202b0a0819b9f4 (diff)
downloadlogilab-common-74f2b4105b32fe719c4ce7ba3ad86f1abe54ed3b.tar.gz
[registry] change select_or_none implementation to remove one level of indirection
Rational: when analyzing cubicweb selectors performance, it has been found that the cost of emiting NoSelectableObject and catching it was higher than returning None and testing for None values. Also, it will be definitly an improvment here as we avoid calling an intermediary function that test for None and raise the exception if needed.
-rw-r--r--registry.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/registry.py b/registry.py
index 4afdfb9..0dc7a21 100644
--- a/registry.py
+++ b/registry.py
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of Logilab-common.
@@ -360,8 +360,8 @@ class Registry(dict):
according to the given context, or None if no object applies.
"""
try:
- return self.select(__oid, *args, **kwargs)
- except (NoSelectableObject, ObjectNotFound):
+ return self._select_best(self[__oid], *args, **kwargs)
+ except ObjectNotFound:
return None
def possible_objects(self, *args, **kwargs):