##// END OF EJS Templates
util._matcher: speed up regexp matching....
Bryan O'Sullivan -
r4371:d7ad1e42 default
parent child Browse files
Show More
@@ -469,22 +469,20 b' def _matcher(canonroot, cwd, names, inc,'
469 """build a matching function from a set of patterns"""
469 """build a matching function from a set of patterns"""
470 if not pats:
470 if not pats:
471 return
471 return
472 matches = []
472 try:
473 for k, p in pats:
473 pat = '(?:%s)' % '|'.join([regex(k, p, tail) for (k, p) in pats])
474 try:
474 return re.compile(pat).match
475 pat = '(?:%s)' % regex(k, p, tail)
475 except re.error:
476 matches.append(re.compile(pat).match)
476 for k, p in pats:
477 except re.error:
477 try:
478 if src: raise Abort("%s: invalid pattern (%s): %s" % (src, k, p))
478 re.compile('(?:%s)' % regex(k, p, tail))
479 else: raise Abort("invalid pattern (%s): %s" % (k, p))
479 except re.error:
480
480 if src:
481 def buildfn(text):
481 raise Abort("%s: invalid pattern (%s): %s" %
482 for m in matches:
482 (src, k, p))
483 r = m(text)
483 else:
484 if r:
484 raise Abort("invalid pattern (%s): %s" % (k, p))
485 return r
485 raise Abort("invalid pattern")
486
487 return buildfn
488
486
489 def globprefix(pat):
487 def globprefix(pat):
490 '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
488 '''return the non-glob prefix of a path, e.g. foo/* -> foo'''
General Comments 0
You need to be logged in to leave comments. Login now