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

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 4, 2014, 3:23 a.m.
Message ID <56043613a4f5c1d0975b.1412393004@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6104/
State Superseded
Headers show

Comments

Siddharth Agarwal - Oct. 4, 2014, 3:23 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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)

Patch

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: