match: optimize _globprefix
authorMatt Mackall <mpm@selenic.com>
Sun, 24 May 2009 02:56:14 -0500
changeset 8575 aa4fcb5c46f1
parent 8574 63a7ed2128d5
child 8576 ec4ed21db4b2
match: optimize _globprefix
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
@@ -63,8 +63,6 @@
         if pat.startswith(prefix + ':'): return pat.split(':', 1)
     return default, pat
 
-_globchars = set('[{*?')
-
 def _globre(pat, head, tail):
     "convert a glob pattern into a regexp"
     i, n = 0, len(pat)
@@ -159,16 +157,12 @@
                 raise util.Abort("invalid pattern (%s): %s" % (k, p))
         raise util.Abort("invalid pattern")
 
-def _containsglob(name):
-    for c in name:
-        if c in _globchars: return True
-    return False
-
 def _globprefix(pat):
     '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
     root = []
     for p in pat.split('/'):
-        if _containsglob(p): break
+        if '[' in p or '{' in p or '*' in p or '?' in p:
+            break
         root.append(p)
     return '/'.join(root) or '.'