diff Lib/macpath.py @ 26627:7babdaea7d19 legacy-trunk

Patch #536661: Improve performance of splitext. Add test_macpath.
author Martin v. Löwis <martin@v.loewis.de>
date Thu, 12 Dec 2002 20:30:20 +0000
parents 4a825b902310
children acdb39b714b1
line wrap: on
line diff
--- a/Lib/macpath.py	Thu Dec 12 20:23:38 2002 +0000
+++ b/Lib/macpath.py	Thu Dec 12 20:30:20 2002 +0000
@@ -62,20 +62,11 @@
     pathname component; the root is everything before that.
     It is always true that root + ext == p."""
 
-    root, ext = '', ''
-    for c in p:
-        if c == ':':
-            root, ext = root + ext + c, ''
-        elif c == '.':
-            if ext:
-                root, ext = root + ext, c
-            else:
-                ext = c
-        elif ext:
-            ext = ext + c
-        else:
-            root = root + c
-    return root, ext
+    i = p.rfind('.')
+    if i<=p.rfind(':'):
+        return p, ''
+    else:
+        return p[:i], p[i:]
 
 
 def splitdrive(p):