equal
deleted
inserted
replaced
2115 revset |
2115 revset |
2116 """ |
2116 """ |
2117 def __init__(self, subset, condition): |
2117 def __init__(self, subset, condition): |
2118 self._subset = subset |
2118 self._subset = subset |
2119 self._condition = condition |
2119 self._condition = condition |
|
2120 self._cache = {} |
2120 |
2121 |
2121 def __contains__(self, x): |
2122 def __contains__(self, x): |
2122 return x in self._subset and self._condition(x) |
2123 c = self._cache |
|
2124 if x not in c: |
|
2125 c[x] = x in self._subset and self._condition(x) |
|
2126 return c[x] |
2123 |
2127 |
2124 def __iter__(self): |
2128 def __iter__(self): |
2125 cond = self._condition |
2129 cond = self._condition |
2126 for x in self._subset: |
2130 for x in self._subset: |
2127 if cond(x): |
2131 if cond(x): |