##// END OF EJS Templates
revset: cache most conditions used in `filter`...
Pierre-Yves David -
r22864:96b6b3d7 default
parent child Browse files
Show More
@@ -2277,7 +2277,7 b' class abstractsmartset(object):'
2277 """Returns a new object with the intersection of the two collections.
2277 """Returns a new object with the intersection of the two collections.
2278
2278
2279 This is part of the mandatory API for smartset."""
2279 This is part of the mandatory API for smartset."""
2280 return self.filter(other.__contains__)
2280 return self.filter(other.__contains__, cache=False)
2281
2281
2282 def __add__(self, other):
2282 def __add__(self, other):
2283 """Returns a new object with the union of the two collections.
2283 """Returns a new object with the union of the two collections.
@@ -2290,15 +2290,18 b' class abstractsmartset(object):'
2290
2290
2291 This is part of the mandatory API for smartset."""
2291 This is part of the mandatory API for smartset."""
2292 c = other.__contains__
2292 c = other.__contains__
2293 return self.filter(lambda r: not c(r))
2293 return self.filter(lambda r: not c(r), cache=False)
2294
2294
2295 def filter(self, condition):
2295 def filter(self, condition, cache=True):
2296 """Returns this smartset filtered by condition as a new smartset.
2296 """Returns this smartset filtered by condition as a new smartset.
2297
2297
2298 `condition` is a callable which takes a revision number and returns a
2298 `condition` is a callable which takes a revision number and returns a
2299 boolean.
2299 boolean.
2300
2300
2301 This is part of the mandatory API for smartset."""
2301 This is part of the mandatory API for smartset."""
2302 # builtin cannot be cached. but do not needs to
2303 if cache and util.safehasattr(condition, 'func_code'):
2304 condition = util.cachefunc(condition)
2302 return filteredset(self, condition)
2305 return filteredset(self, condition)
2303
2306
2304 class baseset(abstractsmartset):
2307 class baseset(abstractsmartset):
General Comments 0
You need to be logged in to leave comments. Login now