encoding: add fast-path for ASCII lowercase
authorMatt Mackall <mpm@selenic.com>
Tue, 10 Apr 2012 12:07:18 -0500
changeset 16387 c481761033bd
parent 16386 ccc173d0914e
child 16388 e03d8a40521f
encoding: add fast-path for ASCII lowercase
mercurial/encoding.py
--- a/mercurial/encoding.py	Tue Apr 10 12:07:16 2012 -0500
+++ b/mercurial/encoding.py	Tue Apr 10 12:07:18 2012 -0500
@@ -168,6 +168,10 @@
 def lower(s):
     "best-effort encoding-aware case-folding of local string s"
     try:
+        return s.encode('ascii').lower()
+    except UnicodeDecodeError:
+        pass
+    try:
         if isinstance(s, localstr):
             u = s._utf8.decode("utf-8")
         else: