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.
This commit is contained in:
Mads Kiilerich 2013-01-29 17:01:41 +01:00
parent e8e2c1e1fe
commit bba6c5042a

View File

@ -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: