develooper Front page | perl.perl5.changes | Postings from October 2020

[Perl/perl5] 1aab53: regcomp.c: Move test earlier in regpiece()

From:
Karl Williamson via perl5-changes
Date:
October 12, 2020 15:46
Subject:
[Perl/perl5] 1aab53: regcomp.c: Move test earlier in regpiece()
Message ID:
Perl/perl5/push/refs/heads/blead/b589cc-2f9be6@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 1aab533b71752bd887772a5c5c5c5480e2c23387
      https://github.com/Perl/perl5/commit/1aab533b71752bd887772a5c5c5c5480e2c23387
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Move test earlier in regpiece()

Prior to this commit, the code checked if this was a particular
quantifier; if so handled that, then checked if it were some other
quantifier, returning if not.

This commit changes to check first if it is any quantifier, using the
macro that checks for all of them, returning if not.

Thus after the new code we know it is a quantifier and this allows later
commits to simplify


  Commit: 7436a695ce7392c1cebf34ae9b05b77c9e5b86f9
      https://github.com/Perl/perl5/commit/7436a695ce7392c1cebf34ae9b05b77c9e5b86f9
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Combine common code

This bit of code occurs in two places.  Move it so that it gets executed
before the split, so it only has to be specified once.


  Commit: e69949b13fa3041e19acb67acf4cfd41b23d60a1
      https://github.com/Perl/perl5/commit/e69949b13fa3041e19acb67acf4cfd41b23d60a1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: White-space only

Outdent since the previous commit removed a surrounding block


  Commit: f02ffedacc1e66d7effee83bc88f7bb8ef0a61a3
      https://github.com/Perl/perl5/commit/f02ffedacc1e66d7effee83bc88f7bb8ef0a61a3
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Move some code in regpiece()

This moves some code, making it part of an if/else.  As a result, several
gotos are eliminated, and the code is in a more logical order.


  Commit: 52750a3e284acba4b68a9316e095851c2c1dd248
      https://github.com/Perl/perl5/commit/52750a3e284acba4b68a9316e095851c2c1dd248
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: White-space only

Outdent since the previous commit removed a surrounding block.
And convert some tabs to blanks


  Commit: 7e450b0a55899945474faeb9de0285d49794df8e
      https://github.com/Perl/perl5/commit/7e450b0a55899945474faeb9de0285d49794df8e
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Rmv misleading comment

This NOTREACHED's presence just before an else would make one think
there is something funny going one, when there isn't.


  Commit: 758976c0689e54ecc5834a1216c648edb300f19d
      https://github.com/Perl/perl5/commit/758976c0689e54ecc5834a1216c648edb300f19d
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Move code to earlier in regpiece()

This is in preparation for a future commit that will change things so
this would need to be done earlier than the changes.


  Commit: 0ad29f588c0a2322ea7edc9f0a120050775466c6
      https://github.com/Perl/perl5/commit/0ad29f588c0a2322ea7edc9f0a120050775466c6
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Rmv #if 0 bitrotted code

This code has been #ifdef'd out for 20 years, and shows bit rot.  It was
kept around in case there was a problem with the replacement for it, but
that hasn't happened and is very unlikely to happen; in the meantime
this is a visual distraction to the code flow.


  Commit: bfed65f5f2d2093415809b85c95155b5c26e195c
      https://github.com/Perl/perl5/commit/bfed65f5f2d2093415809b85c95155b5c26e195c
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece() Don't match 0 length more than once

There's no point in matching something more than once that doesn't
advance the parse, as long as there are no side effects beyond those
from the first match.  Those could only happen in code blocks, which
this code doesn't have.


  Commit: 75ec2ec6d780e09dbf4af12c128f5e1768aa65a8
      https://github.com/Perl/perl5/commit/75ec2ec6d780e09dbf4af12c128f5e1768aa65a8
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece() 0 times anything is 0

Prior to this commit, regpiece() gave width to many quantified values.
This is wrong.  If something is zero width, repeating it doesn't cause
it to gain width.  I don't know if this led to wrong pattern matching
results, but I imagine it led to slower results in some cases.


  Commit: d65eec809ef85dabc6484418ec2b227220003158
      https://github.com/Perl/perl5/commit/d65eec809ef85dabc6484418ec2b227220003158
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece(): Pass along that is a code block

regpiece was failing to pass up to its caller that a piece of code
contained a code block, if that code was quantified.

I don't know what the consequences of this are


  Commit: 789dee0a80b3f71382ec16d0eb3ad448eb8b4425
      https://github.com/Perl/perl5/commit/789dee0a80b3f71382ec16d0eb3ad448eb8b4425
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: Change label name; rmv extraneous goto

The name was misleading.  There are other things being done here.  And
previous restructuring led to a goto immediately prior to where it went
to.


  Commit: f21ef9aab6235ccc523cb726f29ba21a28883bcb
      https://github.com/Perl/perl5/commit/f21ef9aab6235ccc523cb726f29ba21a28883bcb
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece: Consolidate code

There is a common place these three occurrences can be placed at,


  Commit: dd2cafb96f113a74d005d5cbdb410971a0588fb2
      https://github.com/Perl/perl5/commit/dd2cafb96f113a74d005d5cbdb410971a0588fb2
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece(): Refactor two 'if's

I think this makes it clearer the commonalities of the * and +
quantifiers.


  Commit: 5ad205ab3c286bad7c6540a2c8bd53fca3c816f1
      https://github.com/Perl/perl5/commit/5ad205ab3c286bad7c6540a2c8bd53fca3c816f1
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece(): More comments; white-space


  Commit: ff257b759a28ac2e2721a61b98ce5320da581979
      https://github.com/Perl/perl5/commit/ff257b759a28ac2e2721a61b98ce5320da581979
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece(): Convert to a switch() stmt

This makes the code easier to understand, I think.


  Commit: fb138e5e855d79e3ee5c76dba85bc993f729c00f
      https://github.com/Perl/perl5/commit/fb138e5e855d79e3ee5c76dba85bc993f729c00f
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: White-space only

Change indentation to correspond with new blocks formed by the previous
commit


  Commit: 01f72ca30b1f3af6817d4c6c6157af7bd14e46a2
      https://github.com/Perl/perl5/commit/01f72ca30b1f3af6817d4c6c6157af7bd14e46a2
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece: Move chunk of code for clarity

This changes an error branch to be goto'd out of the mainline code.  The
large chunk being in the middle obscured the comonality of the slightly
different non-error cases.

The branch is moved to the bottom of the routine, and croaks, so there
is no return.

This is a modification to a suggestion by Hugo van der Sanden.


  Commit: 2f9be6e9825f6c192746c53107bbffda7e74bbc5
      https://github.com/Perl/perl5/commit/2f9be6e9825f6c192746c53107bbffda7e74bbc5
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  regcomp.c: regpiece: swap order of conditionals

Its a bit more clearer to test the 0 case before the 1 case, and by
doing so it becomes visually easier to compare and contrast the the two
cases.


Compare: https://github.com/Perl/perl5/compare/b589ccd0c210...2f9be6e9825f



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About