OS X: try cheap ascii .lower() in normcase before making full unicode dance stable
authorMads Kiilerich <madski@unity3d.com>
Tue, 29 Jan 2013 17:01:41 +0100
branchstable
changeset 18501 a3b2dc1aa909
parent 18500 f0124a65e8f8
child 18502 68eecbaf1bd3
OS X: try cheap ascii .lower() in normcase before making full unicode dance This is similar to what is done in encoding.lower, introduced in c481761033bd. This has been seen making 'hg up' and 'hg st' in a 50000+ files repo 13% faster. This might make Mercurial slightly slower for users who mainly use non-ASCII filenames. That is a reasonable trade-off.
mercurial/posix.py
--- a/mercurial/posix.py	Tue Jan 29 20:03:51 2013 +0100
+++ b/mercurial/posix.py	Tue Jan 29 17:01:41 2013 +0100
@@ -195,6 +195,11 @@
 
     def normcase(path):
         try:
+            path.decode('ascii') # throw exception for non-ASCII character
+            return path.lower()
+        except UnicodeDecodeError:
+            pass
+        try:
             u = path.decode('utf-8')
         except UnicodeDecodeError:
             # percent-encode any characters that don't round-trip