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

Siddharth Agarwal sid0 at fb.com
Sat Oct 4 14:01:32 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 de61082ab9e70a527885970322c2b1c92035abda
# Parent  d9942c85d5f97c240038bbf302005d47e41c9018
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 where all filenames are ASCII,
hg perfcca:

before: wall 0.260157 comb 0.270000 user 0.230000 sys 0.040000 (best of 38)
after:  wall 0.164616 comb 0.160000 user 0.160000 sys 0.000000 (best of 54)

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