Mercurial > public > mercurial-scm > hg
comparison mercurial/manifest.py @ 24683:4eaea0ed8dc1
manifest.walk: special-case match.always() for speed
This cuts down the run time of
hg files -r . > /dev/null
from ~0.850s to ~0.780s on the Firefox repo. Note that
manifest.matches() already has the corresponding optimization.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 07 Apr 2015 21:08:23 -0700 |
parents | aef3d1469773 |
children | ff7badaf3158 |
comparison
equal
deleted
inserted
replaced
24682:aef3d1469773 | 24683:4eaea0ed8dc1 |
---|---|
220 Equivalent to manifest.matches(match).iterkeys(), but without creating | 220 Equivalent to manifest.matches(match).iterkeys(), but without creating |
221 an entirely new manifest. | 221 an entirely new manifest. |
222 | 222 |
223 It also reports nonexistent files by marking them bad with match.bad(). | 223 It also reports nonexistent files by marking them bad with match.bad(). |
224 ''' | 224 ''' |
225 if match.always(): | |
226 for f in iter(self): | |
227 yield f | |
228 return | |
229 | |
225 fset = set(match.files()) | 230 fset = set(match.files()) |
226 | 231 |
227 # avoid the entire walk if we're only looking for specific files | 232 # avoid the entire walk if we're only looking for specific files |
228 if fset and not match.anypats() and util.all(fn in self for fn in fset): | 233 if fset and not match.anypats() and util.all(fn in self for fn in fset): |
229 for fn in sorted(fset): | 234 for fn in sorted(fset): |
605 Equivalent to manifest.matches(match).iterkeys(), but without creating | 610 Equivalent to manifest.matches(match).iterkeys(), but without creating |
606 an entirely new manifest. | 611 an entirely new manifest. |
607 | 612 |
608 It also reports nonexistent files by marking them bad with match.bad(). | 613 It also reports nonexistent files by marking them bad with match.bad(). |
609 ''' | 614 ''' |
615 if match.always(): | |
616 for f in iter(self): | |
617 yield f | |
618 return | |
619 | |
610 fset = set(match.files()) | 620 fset = set(match.files()) |
611 | 621 |
612 for fn in self._walk(match): | 622 for fn in self._walk(match): |
613 if fn in fset: | 623 if fn in fset: |
614 # specified pattern is the exact name | 624 # specified pattern is the exact name |