Skip to content

Commit 0ae5281

Browse files
committed
toke.c: simplify conflict-marker detection
Since doing this involves a `goto`, hoisting the check to the top of each relevant `case` will make it easier to perform further refactoring.
1 parent 25b56cc commit 0ae5281

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

toke.c

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7213,16 +7213,17 @@ Perl_yylex(pTHX)
72137213
return yyl_verticalbar(aTHX_ s);
72147214

72157215
case '=':
7216+
if (s[1] == '=' && (s == PL_linestart || s[-1] == '\n')
7217+
&& memBEGINs(s + 2, (STRLEN) (PL_bufend - s + 2), "====="))
7218+
{
7219+
s = vcs_conflict_marker(s + 7);
7220+
goto retry;
7221+
}
7222+
72167223
s++;
72177224
{
72187225
const char tmp = *s++;
72197226
if (tmp == '=') {
7220-
if ( (s == PL_linestart+2 || s[-3] == '\n')
7221-
&& memBEGINs(s, (STRLEN) (PL_bufend - s), "====="))
7222-
{
7223-
s = vcs_conflict_marker(s + 5);
7224-
goto retry;
7225-
}
72267227
if (!PL_lex_allbrackets
72277228
&& PL_lex_fakeeof >= LEX_FAKEEOF_COMPARE)
72287229
{
@@ -7307,18 +7308,18 @@ Perl_yylex(pTHX)
73077308
return yyl_bang(aTHX_ s + 1);
73087309

73097310
case '<':
7311+
if (s[1] == '<' && (s == PL_linestart || s[-1] == '\n')
7312+
&& memBEGINs(s+2, (STRLEN) (PL_bufend - (s+2)), "<<<<<"))
7313+
{
7314+
s = vcs_conflict_marker(s + 7);
7315+
goto retry;
7316+
}
7317+
73107318
if (PL_expect != XOPERATOR) {
73117319
if (s[1] != '<' && !memchr(s,'>', PL_bufend - s))
73127320
check_uni();
7313-
if (s[1] == '<' && s[2] != '>') {
7314-
if ( (s == PL_linestart || s[-1] == '\n')
7315-
&& memBEGINs(s+2, (STRLEN) (PL_bufend - (s+2)), "<<<<<"))
7316-
{
7317-
s = vcs_conflict_marker(s + 7);
7318-
goto retry;
7319-
}
7321+
if (s[1] == '<' && s[2] != '>')
73207322
s = scan_heredoc(s);
7321-
}
73227323
else
73237324
s = scan_inputsymbol(s);
73247325
PL_expect = XOPERATOR;
@@ -7328,12 +7329,6 @@ Perl_yylex(pTHX)
73287329
{
73297330
char tmp = *s++;
73307331
if (tmp == '<') {
7331-
if ( (s == PL_linestart+2 || s[-3] == '\n')
7332-
&& memBEGINs(s, (STRLEN) (PL_bufend - s), "<<<<<"))
7333-
{
7334-
s = vcs_conflict_marker(s + 5);
7335-
goto retry;
7336-
}
73377332
if (*s == '=' && !PL_lex_allbrackets
73387333
&& PL_lex_fakeeof >= LEX_FAKEEOF_ASSIGN)
73397334
{
@@ -7369,17 +7364,19 @@ Perl_yylex(pTHX)
73697364
TOKEN(0);
73707365
}
73717366
Rop(OP_LT);
7367+
73727368
case '>':
7369+
if (s[1] == '>' && (s == PL_linestart || s[-1] == '\n')
7370+
&& memBEGINs(s + 2, (STRLEN) (PL_bufend - s + 2), ">>>>>"))
7371+
{
7372+
s = vcs_conflict_marker(s + 7);
7373+
goto retry;
7374+
}
7375+
73737376
s++;
73747377
{
73757378
const char tmp = *s++;
73767379
if (tmp == '>') {
7377-
if ( (s == PL_linestart+2 || s[-3] == '\n')
7378-
&& memBEGINs(s, (STRLEN) (PL_bufend - s), ">>>>>"))
7379-
{
7380-
s = vcs_conflict_marker(s + 5);
7381-
goto retry;
7382-
}
73837380
if (*s == '=' && !PL_lex_allbrackets
73847381
&& PL_lex_fakeeof >= LEX_FAKEEOF_ASSIGN)
73857382
{

0 commit comments

Comments
 (0)