Patchwork [2,of,4] manifest.walk: special-case match.always() for speed

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 9, 2015, 8:31 p.m.
Message ID <a31f6340769584c6badd.1428611513@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8582/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 9, 2015, 8:31 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1428466103 25200
#      Tue Apr 07 21:08:23 2015 -0700
# Node ID a31f6340769584c6baddffb04b0408ced948d94f
# Parent  2823c16b36866512fd18390cd9966e89a6936012
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.

Patch

diff -r 2823c16b3686 -r a31f63407695 mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Apr 07 22:36:17 2015 -0700
+++ b/mercurial/manifest.py	Tue Apr 07 21:08:23 2015 -0700
@@ -222,6 +222,11 @@ 
 
         It also reports nonexistent files by marking them bad with match.bad().
         '''
+        if match.always():
+            for f in iter(self):
+                yield f
+            return
+
         fset = set(match.files())
 
         # avoid the entire walk if we're only looking for specific files
@@ -607,6 +612,11 @@ 
 
         It also reports nonexistent files by marking them bad with match.bad().
         '''
+        if match.always():
+            for f in iter(self):
+                yield f
+            return
+
         fset = set(match.files())
 
         for fn in self._walk(match):