[PATCH] revset: uncache filteredset.__contains__

Yuya Nishihara yuya at tcha.org
Wed Sep 9 15:22:37 UTC 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1441425413 -32400
#      Sat Sep 05 12:56:53 2015 +0900
# Node ID 1d5f8bda8bb9d4d0e4e4b32eed6253e8b7907073
# Parent  29d29a82263f4380a73f05160a03887acf18806a
revset: uncache filteredset.__contains__

Since 96b6b3d78697, condition function returns a cached value, so there's
little benefit to cache __contains__.

No measurable difference found in contrib/base-revsets.txt.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -3077,14 +3077,9 @@ class filteredset(abstractsmartset):
         """
         self._subset = subset
         self._condition = condition
-        self._cache = {}
 
     def __contains__(self, x):
-        c = self._cache
-        if x not in c:
-            v = c[x] = x in self._subset and self._condition(x)
-            return v
-        return c[x]
+        return x in self._subset and self._condition(x)
 
     def __iter__(self):
         return self._iterfilter(self._subset)


More information about the Mercurial-devel mailing list