Skip to content
Snippets Groups Projects
Commit 8306dac48061 authored by Boris Feld's avatar Boris Feld
Browse files

match: extract a literal constant into a symbolic one

parent 0605726179a0
No related branches found
No related tags found
No related merge requests found
......@@ -1184,9 +1184,11 @@
else:
return regex, lambda f: any(mf(f) for mf in matchfuncs)
MAX_RE_SIZE = 20000
def _buildregexmatch(kindpats, globsuffix):
"""Build a match function from a list of kinds and kindpats,
return regexp string and a matcher function."""
try:
regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
for (k, p, s) in kindpats])
......@@ -1187,10 +1189,10 @@
def _buildregexmatch(kindpats, globsuffix):
"""Build a match function from a list of kinds and kindpats,
return regexp string and a matcher function."""
try:
regex = '(?:%s)' % '|'.join([_regex(k, p, globsuffix)
for (k, p, s) in kindpats])
if len(regex) <= 20000:
if len(regex) <= MAX_RE_SIZE:
return regex, _rematcher(regex)
# We're using a Python with a tiny regex engine and we
# made it explode, so we'll divide the pattern list in two
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment