[PATCH 5 of 5] dirstate: cache util.normcase while constructing the foldmap

Siddharth Agarwal sid0 at fb.com
Fri Oct 3 22:23:27 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1412387289 25200
#      Fri Oct 03 18:48:09 2014 -0700
# Node ID 65b511b986e729b7d4c099d5189615973f179965
# Parent  ceee117160a138ef2896111ae699fc74d9048088
dirstate: cache util.normcase while constructing the foldmap

This is a small win on OS X. hg perfdirstatefoldmap:

before: wall 0.406886 comb 0.410000 user 0.390000 sys 0.020000 (best of 25)
after:  wall 0.395550 comb 0.390000 user 0.380000 sys 0.010000 (best of 25)

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -84,11 +84,12 @@
     @propertycache
     def _foldmap(self):
         f = {}
+        normcase = util.normcase
         for name, s in self._map.iteritems():
             if s[0] != 'r':
-                f[util.normcase(name)] = name
+                f[normcase(name)] = name
         for name in self._dirs:
-            f[util.normcase(name)] = name
+            f[normcase(name)] = name
         f['.'] = '.' # prevents useless util.fspath() invocation
         return f
 


More information about the Mercurial-devel mailing list