treemanifest: make hasdir() faster
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 16 Mar 2015 16:01:16 -0700
changeset 24406 1297480ed347
parent 24405 cbe9d50d9e65
child 24408 caa6b6c65dc3
treemanifest: make hasdir() faster Same rationale as the previous change.
mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Mar 03 13:50:06 2015 -0800
+++ b/mercurial/manifest.py	Mon Mar 16 16:01:16 2015 -0700
@@ -506,7 +506,12 @@
         return self._alldirs
 
     def hasdir(self, dir):
-        return dir in self._alldirs
+        topdir, subdir = _splittopdir(dir)
+        if topdir:
+            if topdir in self._dirs:
+                return self._dirs[topdir].hasdir(subdir)
+            return False
+        return (dir + '/') in self._dirs
 
     def matches(self, match):
         '''generate a new manifest filtered by the match argument'''