changeset 24561:6514030dc686

dirstate._normalize: don't construct dirfoldmap if not necessary Constructing the dirfoldmap is expensive, so if there's a hit in the filefoldmap, don't construct the directory foldmap. This helps with cases like 'hg add foo' where foo is already tracked: for a large repository, the operation goes from 1.5 seconds to 1.2 (which is still way too much, but that's a matter for another day.)
author Siddharth Agarwal <sid0@fb.com>
date Tue, 31 Mar 2015 19:34:37 -0700
parents b38bcf18993c
children e55449dae606
files mercurial/dirstate.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Mar 31 19:29:39 2015 -0700
+++ b/mercurial/dirstate.py	Tue Mar 31 19:34:37 2015 -0700
@@ -509,8 +509,9 @@
 
     def _normalize(self, path, isknown, ignoremissing=False, exists=None):
         normed = util.normcase(path)
-        folded = self._filefoldmap.get(normed,
-                                       self._dirfoldmap.get(normed, None))
+        folded = self._filefoldmap.get(normed, None)
+        if folded is None:
+            folded = self._dirfoldmap.get(normed, None)
         if folded is None:
             if isknown:
                 folded = path