# HG changeset patch # User Martin Geisler # Date 1343080526 21600 # Node ID 9fb8312dbdbd2f37a9d9752a1ee310eb974520ab # Parent 3745ae495ce5c6d021d5519a436b2f51005e8d8d encoding: add fast-path for ASCII uppercase. This copies the performance hack from encoding.lower (c481761033bd). The case-folding logic that kicks in on case-insensitive filesystems hits encoding.upper hard: with a repository with 75k files, the timings went from hg perfstatus ! wall 3.156000 comb 3.156250 user 1.625000 sys 1.531250 (best of 3) to hg perfstatus ! wall 2.390000 comb 2.390625 user 1.078125 sys 1.312500 (best of 5) This is a 24% decrease. For comparison, Mercurial 2.0 gives: hg perfstatus ! wall 2.172000 comb 2.171875 user 0.984375 sys 1.187500 (best of 5) so we're only 10% slower than before we added the extra case-folding logic. The same decrease is seen when executing 'hg status' as normal, where we go from: hg status --time time: real 4.322 secs (user 2.219+0.000 sys 2.094+0.000) to hg status --time time: real 3.307 secs (user 1.750+0.000 sys 1.547+0.000) diff -r 3745ae495ce5 -r 9fb8312dbdbd mercurial/encoding.py --- a/mercurial/encoding.py Mon Jul 23 15:55:22 2012 -0600 +++ b/mercurial/encoding.py Mon Jul 23 15:55:26 2012 -0600 @@ -190,6 +190,11 @@ def upper(s): "best-effort encoding-aware case-folding of local string s" try: + s.decode('ascii') # throw exception for non-ASCII character + return s.upper() + except UnicodeDecodeError: + pass + try: if isinstance(s, localstr): u = s._utf8.decode("utf-8") else: