match: optimize _patsplit
authorMatt Mackall <mpm@selenic.com>
Sun, 24 May 2009 02:56:14 -0500
changeset 8579 aff7f83c365b
parent 8578 8388ef8d21cd
child 8580 f648c096f6d0
match: optimize _patsplit
mercurial/match.py
--- a/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
+++ b/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
@@ -59,8 +59,10 @@
 def _patsplit(pat, default):
     """Split a string into an optional pattern kind prefix and the
     actual pattern."""
-    for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre':
-        if pat.startswith(prefix + ':'): return pat.split(':', 1)
+    if ':' in pat:
+        pat, val = pat.split(':', 1)
+        if pat in ('re', 'glob', 'path', 'relglob', 'relpath', 'relre'):
+            return pat, val
     return default, pat
 
 def _globre(pat, head, tail):