changeset 40774:8306dac48061

match: extract a literal constant into a symbolic one
author Boris Feld <boris.feld@octobus.net>
date Thu, 22 Nov 2018 17:20:32 +0100
parents 0605726179a0
children 4e02f25f31c6
files mercurial/match.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sat Dec 01 21:42:48 2018 -0500
+++ b/mercurial/match.py	Thu Nov 22 17:20:32 2018 +0100
@@ -1184,13 +1184,15 @@
     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])
-        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