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

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 4, 2014, 7:01 p.m.
Message ID <2d1097ad01e822e198df.1412449295@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6120/
State Accepted
Commit a1eb21f5caea4366310e32aa85248791d5bbfa0c
Headers show

Comments

Siddharth Agarwal - Oct. 4, 2014, 7:01 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1412387289 25200
#      Fri Oct 03 18:48:09 2014 -0700
# Node ID 2d1097ad01e822e198dfaad474fcda5de34a0a1a
# Parent  c83e9a5d2dc56c0a0a48d84af2aefc67518d8e9f
dirstate: cache util.normcase while constructing the foldmap

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

before: wall 0.399708 comb 0.410000 user 0.390000 sys 0.020000 (best of 25)
after:  wall 0.386331 comb 0.390000 user 0.370000 sys 0.020000 (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