[PATCH 2 of 5] encoding.lower: use fast ASCII lower

Siddharth Agarwal sid0 at fb.com
Fri Oct 3 22:23:24 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1412387156 25200
#      Fri Oct 03 18:45:56 2014 -0700
# Node ID 56043613a4f5c1d0975b7eb30577284fe33c1edf
# Parent  cb91516e7745b936b8b70dbef1535cbc39d53277
encoding.lower: use fast ASCII lower

This benefits, among other things, the case collision auditor.

On a Linux system with a large real-world repo with only ASCII files,
hg perfcca:

before: 0.260157 comb 0.270000 user 0.230000 sys 0.040000 (best of 38)
after:  0.167446 comb 0.170000 user 0.170000 sys 0.000000 (best of 50)

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -275,8 +275,7 @@
 def lower(s):
     "best-effort encoding-aware case-folding of local string s"
     try:
-        s.decode('ascii') # throw exception for non-ASCII character
-        return s.lower()
+        return asciilower(s)
     except UnicodeDecodeError:
         pass
     try:


More information about the Mercurial-devel mailing list