# HG changeset patch # User Siddharth Agarwal # Date 2015-04-01 02:34:37 # Node ID 6514030dc6864a9287e7f50ca65abfb80f154847 # Parent b38bcf18993cd9cbdade07834061659b631c4d8c 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.) diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -509,8 +509,9 @@ class dirstate(object): 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