changeset 16387:c481761033bd

encoding: add fast-path for ASCII lowercase
author Matt Mackall <mpm@selenic.com>
date Tue, 10 Apr 2012 12:07:18 -0500
parents ccc173d0914e
children e03d8a40521f
files mercurial/encoding.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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: