Patchwork [2,of,6,V3] match: extract a literal constant into a symbolic one

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 2:12 p.m.
Message ID <8847fda442975010d004.1542982365@localhost.localdomain>
Download mbox | patch
Permalink /patch/36744/
State Accepted
Headers show

Comments

Boris Feld - Nov. 23, 2018, 2:12 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542903632 -3600
#      Thu Nov 22 17:20:32 2018 +0100
# Node ID 8847fda442975010d004dcb0293a40ba70434070
# Parent  917fa088dd67d1f56c751de59acc91abc799d83a
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 8847fda44297
match: extract a literal constant into a symbolic one

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1184,13 +1184,15 @@  def _buildmatch(kindpats, globsuffix, li
     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:
             raise OverflowError
         return regex, _rematcher(regex)
     except OverflowError: