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

login
register
mail settings
Submitter Boris Feld
Date Nov. 22, 2018, 10:17 p.m.
Message ID <7540e746d44775c7098d.1542925039@localhost.localdomain>
Download mbox | patch
Permalink /patch/36724/
State Superseded
Headers show

Comments

Boris Feld - Nov. 22, 2018, 10:17 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 7540e746d44775c7098d5fa473be9968317616f1
# Parent  98300756a74d424fcd1510b0bb98f07b9b0f8663
# EXP-Topic perf-ignore-2
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7540e746d447
match: extract a literal constant into a symbolic one
via Mercurial-devel - Nov. 23, 2018, 7:17 a.m.
On Thu, Nov 22, 2018 at 2:21 PM Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542903632 -3600
> #      Thu Nov 22 17:20:32 2018 +0100
> # Node ID 7540e746d44775c7098d5fa473be9968317616f1
> # Parent  98300756a74d424fcd1510b0bb98f07b9b0f8663
> # EXP-Topic perf-ignore-2
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 7540e746d447
> match: extract a literal constant into a symbolic one
>
> 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)
>
> +MAXRESIZE = 20000


Would be clearer as MAX_RE_SIZE or MAX_REGEX_SIZE (it's very easy to parse
the current name as "max resize")
Boris FELD - Nov. 23, 2018, 5:17 p.m.
On 23/11/2018 08:17, Martin von Zweigbergk via Mercurial-devel wrote:
>
>
> On Thu, Nov 22, 2018 at 2:21 PM Boris Feld <boris.feld@octobus.net
> <mailto:boris.feld@octobus.net>> wrote:
>
>     # HG changeset patch
>     # User Boris Feld <boris.feld@octobus.net
>     <mailto:boris.feld@octobus.net>>
>     # Date 1542903632 -3600
>     #      Thu Nov 22 17:20:32 2018 +0100
>     # Node ID 7540e746d44775c7098d5fa473be9968317616f1
>     # Parent  98300756a74d424fcd1510b0bb98f07b9b0f8663
>     # EXP-Topic perf-ignore-2
>     # Available At https://bitbucket.org/octobus/mercurial-devel/
>     #              hg pull
>     https://bitbucket.org/octobus/mercurial-devel/ -r 7540e746d447
>     match: extract a literal constant into a symbolic one
>
>     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)
>
>     +MAXRESIZE = 20000
>
>
> Would be clearer as MAX_RE_SIZE or MAX_REGEX_SIZE (it's very easy to
> parse the current name as "max resize")
We would be more than happy to use '_' here. What're the new rules
regarding '_'? Where can we use them and where can we not?
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
via Mercurial-devel - Nov. 23, 2018, 10:33 p.m.
On Fri, Nov 23, 2018 at 9:17 AM Boris FELD <lothiraldan@gmail.com> wrote:

> On 23/11/2018 08:17, Martin von Zweigbergk via Mercurial-devel wrote:
>
>
>
> On Thu, Nov 22, 2018 at 2:21 PM Boris Feld <boris.feld@octobus.net> wrote:
>
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1542903632 -3600
>> #      Thu Nov 22 17:20:32 2018 +0100
>> # Node ID 7540e746d44775c7098d5fa473be9968317616f1
>> # Parent  98300756a74d424fcd1510b0bb98f07b9b0f8663
>> # EXP-Topic perf-ignore-2
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
>> 7540e746d447
>> match: extract a literal constant into a symbolic one
>>
>> 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)
>>
>> +MAXRESIZE = 20000
>
>
> Would be clearer as MAX_RE_SIZE or MAX_REGEX_SIZE (it's very easy to parse
> the current name as "max resize")
>
> We would be more than happy to use '_' here. What're the new rules
> regarding '_'? Where can we use them and where can we not?
>

I don't know, but there are many instances of constants with this style in
revlog.py, so I think it should be fine. I'd happily queue it anyway, and
if someone objects, we can drop the underscores in a follow-up patch (seems
unlikely to happen).


> _______________________________________________
> Mercurial-devel mailing listMercurial-devel@mercurial-scm.orghttps://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
>

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)
 
+MAXRESIZE = 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) > MAXRESIZE:
             raise OverflowError
         return regex, _rematcher(regex)
     except OverflowError: