diff options
author | Karl Williamson <khw@cpan.org> | 2017-02-13 11:51:59 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-02-13 21:24:08 -0700 |
commit | 07337b9591822033e937370211f01ca63f3243f1 (patch) | |
tree | a1bc15a3dc4cb5e4fab9b9564daf4033f9361756 /toke.c | |
parent | 218304f90362a79b96bb58e1ef63c0f213451079 (diff) | |
download | perl-07337b9591822033e937370211f01ca63f3243f1.tar.gz |
toke.c: Slight refactor.
This moves an automatic variable to closer to the only place it is used;
it also adds branch prediction. It is likely that the input will be
well-formed.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -1309,7 +1309,6 @@ Perl_lex_next_chunk(pTHX_ U32 flags) STRLEN linestart_pos, last_uni_pos, last_lop_pos; bool got_some_for_debugger = 0; bool got_some; - const U8* first_bad_char_loc; if (flags & ~(LEX_KEEP_PREVIOUS|LEX_FAKE_EOF|LEX_NO_TERM)) Perl_croak(aTHX_ "Lexing code internal error (%s)", "lex_next_chunk"); @@ -1376,15 +1375,19 @@ Perl_lex_next_chunk(pTHX_ U32 flags) PL_parser->bufend = buf + new_bufend_pos; PL_parser->bufptr = buf + bufptr_pos; - if (UTF && ! is_utf8_string_loc((U8 *) PL_parser->bufptr, - PL_parser->bufend - PL_parser->bufptr, - &first_bad_char_loc)) - { - _force_out_malformed_utf8_message(first_bad_char_loc, - (U8 *) PL_parser->bufend, - 0, - 1 /* 1 means die */ ); - NOT_REACHED; /* NOTREACHED */ + if (UTF) { + const U8* first_bad_char_loc; + if (UNLIKELY(! is_utf8_string_loc( + (U8 *) PL_parser->bufptr, + PL_parser->bufend - PL_parser->bufptr, + &first_bad_char_loc))) + { + _force_out_malformed_utf8_message(first_bad_char_loc, + (U8 *) PL_parser->bufend, + 0, + 1 /* 1 means die */ ); + NOT_REACHED; /* NOTREACHED */ + } } PL_parser->oldbufptr = buf + oldbufptr_pos; |