Mercurial > hg-stable
changeset 8575:aa4fcb5c46f1
match: optimize _globprefix
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 24 May 2009 02:56:14 -0500 |
parents | 63a7ed2128d5 |
children | ec4ed21db4b2 |
files | mercurial/match.py |
diffstat | 1 files changed, 2 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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 '.'