# HG changeset patch # User Matt Mackall # Date 2009-05-24 07:56:14 # Node ID aff7f83c365b41b24fd6dc6b420cb2936dce812d # Parent 8388ef8d21cdc8445718927c52db0c6a0065cc31 match: optimize _patsplit diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -59,8 +59,10 @@ def patkind(pat): 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):