Mercurial > hg
changeset 40776:ce401300f981
match: extract function that group regexps
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 22 Nov 2018 17:25:49 +0100 |
parents | 4e02f25f31c6 |
children | 3c842749debc |
files | mercurial/match.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/match.py Thu Nov 22 17:16:05 2018 +0100 +++ b/mercurial/match.py Thu Nov 22 17:25:49 2018 +0100 @@ -1186,6 +1186,10 @@ MAX_RE_SIZE = 20000 +def _joinregexes(regexps): + """gather multiple regular expressions into a single one""" + return '(?:%s)' % '|'.join(regexps) + def _buildregexmatch(kindpats, globsuffix): """Build a match function from a list of kinds and kindpats, return regexp string and a matcher function. @@ -1199,7 +1203,7 @@ OverflowError """ try: - regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix) + regex = _joinregexes([_regex(k, p, globsuffix) for (k, p, s) in kindpats]) if len(regex) <= MAX_RE_SIZE: return regex, _rematcher(regex)