[PATCH 3 of 4] manifestdict: inline _intersectfiles()

Martin von Zweigbergk martinvonz at google.com
Wed Apr 8 14:58:04 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1428512491 25200
#      Wed Apr 08 10:01:31 2015 -0700
# Node ID 0ea055b50b25af563a7f0956acf6ee465217f10b
# Parent  12c2a79698df71be5823331cac70bfc8b042a88b
manifestdict: inline _intersectfiles()

The _intersectfiles() method is only called from one place, it's
pretty short, and its caller has to be aware when it's appropriate to
call it (when the number of files in the matcher is not too large), so
let's inline it.

diff -r 12c2a79698df -r 0ea055b50b25 mercurial/manifest.py
--- a/mercurial/manifest.py	Wed Apr 08 10:03:59 2015 -0700
+++ b/mercurial/manifest.py	Wed Apr 08 10:01:31 2015 -0700
@@ -198,17 +198,6 @@
     def keys(self):
         return list(self.iterkeys())
 
-    def _intersectfiles(self, files):
-        '''make a new lazymanifest with the intersection of self with files
-
-        The algorithm assumes that files is much smaller than self.'''
-        ret = manifestdict()
-        lm = self._lm
-        for fn in files:
-            if fn in lm:
-                ret._lm[fn] = lm[fn]
-        return ret
-
     def filesnotin(self, m2):
         '''Set of files in this manifest that are not in the other'''
         files = set(self)
@@ -265,7 +254,12 @@
         files = match.files()
         if (len(files) < 100 and (match.isexact() or
             (not match.anypats() and util.all(fn in self for fn in files)))):
-            return self._intersectfiles(files)
+            m = manifestdict()
+            lm = self._lm
+            for fn in match.files():
+                if fn in lm:
+                    m._lm[fn] = lm[fn]
+            return m
 
         m = manifestdict('')
         m._lm = self._lm.filtercopy(match)


More information about the Mercurial-devel mailing list