[PATCH 3 of 5] match: drop optimization (?) of 'parentdirs' calculation

Martin von Zweigbergk martinvonz at google.com
Mon Jun 15 12:13:52 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1432752475 25200
#      Wed May 27 11:47:55 2015 -0700
# Node ID 84c443448e36de7bda8ec85dc1c96d539712b5f3
# Parent  58744830c148bbc93e3947b8a7b9c85ecd320f0a
match: drop optimization (?) of 'parentdirs' calculation

It seems unlikely that the optimization to avoid calling util.finddirs
twice will be noticeable, so let's drop it. This makes the two
conditions for includes and regular patterns more similar.

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -224,19 +224,18 @@
         '''
         if dir in self._excluderoots:
             return False
-        parentdirs = None
         if (self._includeroots and
             dir not in self._includeroots and
             dir not in self._includedirs):
-            parentdirs = list(util.finddirs(dir))
-            if not any(parent in self._includeroots for parent in parentdirs):
+            if not any(parent in self._includeroots
+                       for parent in util.finddirs(dir)):
                 return False
         return (not self._fileroots or
                 '.' in self._fileroots or
                 dir in self._fileroots or
                 dir in self._dirs or
                 any(parentdir in self._fileroots
-                    for parentdir in parentdirs or util.finddirs(dir)))
+                    for parentdir in util.finddirs(dir)))
 
     def exact(self, f):
         '''Returns True if f is in .files().'''


More information about the Mercurial-devel mailing list