# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 2015-03-30 01:28:48
# Node ID a4b81dbe73c1c0420dfda49e9c8e68c8f4a77946
# Parent  18085e46caa92553018c78fd210f31a88a28912c

dirstate._walkexplicit: don't bother normalizing '.'

The overwhelmingly common case is running commands like 'hg diff' with no
arguments. Therefore the only file that'll be listed is the root directory.
Normalizing that's just a waste of time.

This means that for a plain 'hg diff' we'll never need to construct the
foldmap, saving us a significant chunk of time.

On case-insensitive HFS+ on OS X, for a large repository with over 200,000
files, this brings down 'hg diff' from 2.97 seconds to 2.36.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -634,7 +634,9 @@ class dirstate(object):
 
         alldirs = None
         for ff in files:
-            if normalize:
+            # constructing the foldmap is expensive, so don't do it for the
+            # common case where files is ['.']
+            if normalize and ff != '.':
                 nf = normalize(ff, False, True)
             else:
                 nf = ff