[PATCH 4 of 4 STABLE] windows: use 'str.replace()' instead of combination of split() and join()

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Feb 5 08:39:44 CST 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1328450311 -32400
# Branch stable
# Node ID 80aeb38a7c5cf47e23a77b5aab820fd720670b52
# Parent  73aaff46175b17b03283369d92fd2f0aa88a2644
windows: use 'str.replace()' instead of combination of split() and join()

'str.replace()' is twice (or more) as fast as combination of split()
and join().

combination of split() and join() in current 'util.pconvert()'
implementation comes only from historical reason when win32mbcs
extension was introduced.

diff -r 73aaff46175b -r 80aeb38a7c5c mercurial/windows.py
--- a/mercurial/windows.py	Sun Feb 05 22:58:31 2012 +0900
+++ b/mercurial/windows.py	Sun Feb 05 22:58:31 2012 +0900
@@ -123,7 +123,7 @@
         msvcrt.setmode(fno(), os.O_BINARY)
 
 def pconvert(path):
-    return '/'.join(path.split(os.sep))
+    return path.replace(os.sep, '/')
 
 def localpath(path):
     return path.replace('/', '\\')


More information about the Mercurial-devel mailing list