From bba6c5042a9724cbe9a158f240d01c00564308bb Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Tue, 29 Jan 2013 17:01:41 +0100 Subject: [PATCH] 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 e7a5733d533f. 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mercurial/posix.py b/mercurial/posix.py index 3782be4dde..bbb2a2affa 100644 --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -194,6 +194,11 @@ if sys.platform == 'darwin': import fcntl # only needed on darwin, missing on jython 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: