Skip to content

Commit

Permalink
regmatch(): remove reginput from CURLYM
Browse files Browse the repository at this point in the history
reginput, locinput and st->locinput were being used in a little
ballet to determine the length of the first match.
This is now simply locinput - st->locinput, or its unicode equivalent;
so the code can be simplified.

Elsewhere in the block: where reginput was being used, locinput and/or
nextchr already contain the same info, so use them instead.

This is part of a campaign to eliminate the reginput variable.
  • Loading branch information
iabyn committed Sep 14, 2012
1 parent 37f5397 commit c07e9d7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions regexec.c
Expand Up @@ -5235,21 +5235,18 @@ NULL
assert(0); /* NOTREACHED */

case CURLYM_A: /* we've just matched an A */
locinput = st->locinput;
nextchr = UCHARAT(locinput);

ST.count++;
/* after first match, determine A's length: u.curlym.alen */
if (ST.count == 1) {
if (PL_reg_match_utf8) {
char *s = locinput;
while (s < reginput) {
char *s = st->locinput;
while (s < locinput) {
ST.alen++;
s += UTF8SKIP(s);
}
}
else {
ST.alen = reginput - locinput;
ST.alen = locinput - st->locinput;
}
if (ST.alen == 0)
ST.count = ST.minmod ? ARG1(ST.me) : ARG2(ST.me);
Expand All @@ -5261,8 +5258,6 @@ NULL
(IV) ST.count, (IV)ST.alen)
);

locinput = reginput;

if (cur_eval && cur_eval->u.eval.close_paren &&
cur_eval->u.eval.close_paren == (U32)ST.me->flags)
goto fake_end;
Expand All @@ -5283,7 +5278,6 @@ NULL
sayNO;

curlym_do_B: /* execute the B in /A{m,n}B/ */
reginput = locinput;
if (ST.c1 == CHRTEST_UNINIT) {
/* calculate c1 and c2 for possible match of 1st char
* following curly */
Expand Down Expand Up @@ -5325,8 +5319,8 @@ NULL
"", (IV)ST.count)
);
if (ST.c1 != CHRTEST_VOID
&& UCHARAT(reginput) != ST.c1
&& UCHARAT(reginput) != ST.c2)
&& nextchr != ST.c1
&& nextchr != ST.c2)
{
/* simulate B failing */
DEBUG_OPTIMISE_r(
Expand All @@ -5344,8 +5338,8 @@ NULL
I32 paren = ST.me->flags;
if (ST.count) {
rex->offs[paren].start
= HOPc(reginput, -ST.alen) - PL_bostr;
rex->offs[paren].end = reginput - PL_bostr;
= HOPc(locinput, -ST.alen) - PL_bostr;
rex->offs[paren].end = locinput - PL_bostr;
if ((U32)paren > rex->lastparen)
rex->lastparen = paren;
rex->lastcloseparen = paren;
Expand Down Expand Up @@ -5379,6 +5373,7 @@ NULL
sayNO;
ST.count--;
locinput = HOPc(locinput, -ST.alen);
nextchr = UCHARAT(locinput);
goto curlym_do_B; /* try to match B */

#undef ST
Expand Down

0 comments on commit c07e9d7

Please sign in to comment.