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

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 4, 2014, 3:23 a.m.
Message ID <65b511b986e729b7d4c0.1412393007@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6106/
State Superseded
Headers show

Comments

Siddharth Agarwal - Oct. 4, 2014, 3:23 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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)

Patch

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