toke.c: Set PL_lex_state less when scanning formats
authorFather Chrysostomos <sprout@cpan.org>
Thu, 9 Aug 2012 06:12:59 +0000 (23:12 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 10 Aug 2012 20:32:28 +0000 (13:32 -0700)
commit5c9ae74dcaf4a16d67145fc3ea876a42aeb5c0b3
treef2fac3d4ffee8b9888c0c09c0bf8a18ae989adb9
parent96f9b7829bf7acfe4d793430f9fd6ca003f6d481
toke.c: Set PL_lex_state less when scanning formats

This (in yylex) is the only code that calls scan_formline:

    case LEX_FORMLINE:
PL_lex_state = PL_parser->form_lex_state;
s = scan_formline(PL_bufptr);
if (!PL_lex_formbrack)
{
    formbrack = 1;
    goto rightbracket;
}
PL_bufptr = s;
return yylex();
    }

It is only reached when PL_lex_state is LEX_FORMLINE.  scan_formline
itself does not even look at PL_lex_state.  It does set it, though,
unless it has reached the end of the format (setting PL_lex_formbrack
to 0) or the end of input.

This means we end up flipping it back and forth between two values.

We don’t have to set PL_lex_state before scan_formline() at all.  Hav-
ing scan_formline only set it when it does not need to be LEX_FORMLINE
simplifies things, resulting in less code and fewer assignments.
toke.c