Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 22779:d9585dda63c3
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)
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 03 Oct 2014 18:45:56 -0700 |
parents | 80f2b63dd83a |
children | bcff9ecdaae0 |
comparison
equal
deleted
inserted
replaced
22778:80f2b63dd83a | 22779:d9585dda63c3 |
---|---|
268 asciilower = getattr(parsers, 'asciilower', asciilower) | 268 asciilower = getattr(parsers, 'asciilower', asciilower) |
269 | 269 |
270 def lower(s): | 270 def lower(s): |
271 "best-effort encoding-aware case-folding of local string s" | 271 "best-effort encoding-aware case-folding of local string s" |
272 try: | 272 try: |
273 s.decode('ascii') # throw exception for non-ASCII character | 273 return asciilower(s) |
274 return s.lower() | |
275 except UnicodeDecodeError: | 274 except UnicodeDecodeError: |
276 pass | 275 pass |
277 try: | 276 try: |
278 if isinstance(s, localstr): | 277 if isinstance(s, localstr): |
279 u = s._utf8.decode("utf-8") | 278 u = s._utf8.decode("utf-8") |