Patchwork [6,of,6,V3] treemanifest: make hasdir() faster

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 19, 2015, 7:52 p.m.
Message ID <53513343144e980b1cf9.1426794778@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8177/
State Accepted
Commit 1297480ed347e9506a213b9998ad6eb200480dfa
Headers show

Comments

Martin von Zweigbergk - March 19, 2015, 7:52 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426546876 25200
#      Mon Mar 16 16:01:16 2015 -0700
# Node ID 53513343144e980b1cf979285ddfb58b8fa8307c
# Parent  ac74c8fcc0bb7eed6abee79500fcb88047593ae4
treemanifest: make hasdir() faster

Same rationale as the previous change.
Matt Mackall - March 19, 2015, 10:10 p.m.
On Thu, 2015-03-19 at 12:52 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1426546876 25200
> #      Mon Mar 16 16:01:16 2015 -0700
> # Node ID 53513343144e980b1cf979285ddfb58b8fa8307c
> # Parent  ac74c8fcc0bb7eed6abee79500fcb88047593ae4
> treemanifest: make hasdir() faster

These are queued for default, thanks.

Patch

diff -r ac74c8fcc0bb -r 53513343144e 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'''