Patchwork [4,of,5] normcase: for darwin, use fast ASCII lower

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

Comments

Siddharth Agarwal - Oct. 4, 2014, 3:23 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1412387248 25200
#      Fri Oct 03 18:47:28 2014 -0700
# Node ID ceee117160a138ef2896111ae699fc74d9048088
# Parent  5b9344d9025ff4325805b87ff53e3656778193f6
normcase: for darwin, use fast ASCII lower

Constructing the foldmap is much faster on OS X now. For a large real-world repo:

before: wall 0.805278 comb 0.800000 user 0.790000 sys 0.010000 (best of 13)
after:  wall 0.407404 comb 0.410000 user 0.390000 sys 0.020000 (best of 25)

This is a nice boost to 'hg status', especially with the third-party hgwatchman
extension enabled (which eliminates stat calls). For the above repo, 'hg
status' goes from 1.17 seconds to 0.75.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -217,8 +217,7 @@ 
         '''
 
         try:
-            path.decode('ascii') # throw exception for non-ASCII character
-            return path.lower()
+            return encoding.asciilower(path)  # exception for non-ASCII
         except UnicodeDecodeError:
             pass
         try: