comparison mercurial/revset.py @ 26306:d157e1f18e3f

revset: speed up existence checks for ordered filtered sets Previously, calling 'if foo:' on a ordered filtered set would start iterating in whatever the current direction was and return if a value was available. If the current direction was ascending, but the set had a fastdesc available, this meant we did a lot more work than necessary. If this was applied without my previous max/min fixes, it would improve max() performance (this was my first attempt at fixing the issue). Since those previous fixes went in though, this doesn't have a visible benefit in the benchmarks, but it does seem clearly better than it was before so I think it should still go in.
author Durham Goode <durham@fb.com>
date Sun, 20 Sep 2015 16:53:42 -0700
parents ade5c488d622
children 428a8747f4ee
comparison
equal deleted inserted replaced
26305:ade5c488d622 26306:d157e1f18e3f
3223 if it is None: 3223 if it is None:
3224 return None 3224 return None
3225 return lambda: self._iterfilter(it()) 3225 return lambda: self._iterfilter(it())
3226 3226
3227 def __nonzero__(self): 3227 def __nonzero__(self):
3228 for r in self: 3228 it = self
3229 fast = self.fastasc or self.fastdesc
3230 if fast:
3231 it = fast()
3232
3233 for r in it:
3229 return True 3234 return True
3230 return False 3235 return False
3231 3236
3232 def __len__(self): 3237 def __len__(self):
3233 # Basic implementation to be changed in future patches. 3238 # Basic implementation to be changed in future patches.