Patch #536661: Improve performance of splitext. Add test_macpath.
diff --git a/Lib/macpath.py b/Lib/macpath.py
index f19b4f7..734bae2 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -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):