comparison mercurial/revset.py @ 26212:0d8df1f510c6

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.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 05 Sep 2015 12:56:53 +0900
parents 42bb1812686f
children 43f9976346e9
comparison
equal deleted inserted replaced
26211:ea489d94e1dc 26212:0d8df1f510c6
3075 condition: a function that decide whether a revision in the subset 3075 condition: a function that decide whether a revision in the subset
3076 belongs to the revset or not. 3076 belongs to the revset or not.
3077 """ 3077 """
3078 self._subset = subset 3078 self._subset = subset
3079 self._condition = condition 3079 self._condition = condition
3080 self._cache = {}
3081 3080
3082 def __contains__(self, x): 3081 def __contains__(self, x):
3083 c = self._cache 3082 return x in self._subset and self._condition(x)
3084 if x not in c:
3085 v = c[x] = x in self._subset and self._condition(x)
3086 return v
3087 return c[x]
3088 3083
3089 def __iter__(self): 3084 def __iter__(self):
3090 return self._iterfilter(self._subset) 3085 return self._iterfilter(self._subset)
3091 3086
3092 def _iterfilter(self, it): 3087 def _iterfilter(self, it):