changeset 21880:e6754f5e4cf7

context: generate filtered manifest efficiently for exact matchers When the matcher is exact, there's no reason to iterate over the entire manifest. It's much more efficient to iterate over the list of files instead. For a repository with approximately 300,000 files, this speeds up hg log -l10 --patch --follow for a frequently modified file from 16.5 seconds to 10.5 seconds.
author Siddharth Agarwal <sid0@fb.com>
date Sat, 12 Jul 2014 17:59:03 -0700
parents 090dcaaf3fff
children 6f332778f904
files mercurial/context.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sat Jul 12 17:57:25 2014 -0700
+++ b/mercurial/context.py	Sat Jul 12 17:59:03 2014 -0700
@@ -71,9 +71,13 @@
         object oriented way for other contexts to customize the manifest
         generation.
         """
+        if match.always():
+            return self.manifest().copy()
+
+        if match.matchfn == match.exact:
+            return self.manifest().intersectfiles(match.files())
+
         mf = self.manifest().copy()
-        if match.always():
-            return mf
         for fn in mf.keys():
             if not match(fn):
                 del mf[fn]