revset: reduce dict lookup in lazyset.__contains__
authorPierre-Yves David <pierre-yves.david@fb.com>
Fri, 25 Apr 2014 14:51:24 -0700
changeset 22527 6e38b5d49977
parent 22526 1e6d2b6b37ea
child 22528 b6dc3b79bb25
revset: reduce dict lookup in lazyset.__contains__ Avoid an extra dict lookup when we have to compute the value. No visible performance impact but this shaves the yak a few extra nanometers.
mercurial/revset.py
--- a/mercurial/revset.py	Fri Apr 25 17:53:58 2014 -0700
+++ b/mercurial/revset.py	Fri Apr 25 14:51:24 2014 -0700
@@ -2342,7 +2342,8 @@
     def __contains__(self, x):
         c = self._cache
         if x not in c:
-            c[x] = x in self._subset and self._condition(x)
+            v = c[x] = x in self._subset and self._condition(x)
+            return v
         return c[x]
 
     def __iter__(self):