Skip to content

Commit a9ebc12

Browse files
committed
S_parse_ident: Collapse two branches into one
These branches differ only 1) in part of the conditions that indicate to take them, so combine those conditions together, 2) the number of bytes to advance, which is easily determinable Otherwise they are identical, so it is easier to understand if they are made common
1 parent 3759405 commit a9ebc12

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

toke.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10379,32 +10379,24 @@ S_parse_ident(pTHX_ const char *s, const char * const s_end,
1037910379
} while (isWORDCHAR_A(*s));
1038010380
}
1038110381
else if ( allow_package
10382-
&& *s == '\''
10383-
&& FEATURE_APOS_AS_NAME_SEP_IS_ENABLED
10384-
&& isIDFIRST_lazy_if_safe(s + 1, s_end, is_utf8))
10385-
{ /* Convert the apostrophe to "::" */
10386-
if (*d >= e - 2) {
10387-
goto too_long;
10388-
}
10389-
10390-
*(*d)++ = ':';
10391-
*(*d)++ = ':';
10392-
s++;
10393-
}
10394-
else if (allow_package && *s == ':' && s[1] == ':'
10395-
/* Disallow things like Foo::$bar. For the curious, this is
10396-
* the code path that triggers the "Bad name after" warning
10397-
* when looking for barewords.
10398-
*/
10399-
&& !(check_dollar && s[2] == '$'))
10382+
&& ( ( *s == '\''
10383+
&& FEATURE_APOS_AS_NAME_SEP_IS_ENABLED
10384+
&& isIDFIRST_lazy_if_safe(s+1, s_end, is_utf8))
10385+
/* Below we convert the apostrophe to "::" */
10386+
|| ( *s == ':' && s[1] == ':'
10387+
/* Disallow things like Foo::$bar. For the
10388+
* curious, this is the code path that triggers
10389+
* the "Bad name after" warning when looking for
10390+
* barewords. */
10391+
&& !(check_dollar && s[2] == '$'))))
1040010392
{
1040110393
if (*d >= e - 2) {
1040210394
goto too_long;
1040310395
}
1040410396

1040510397
*(*d)++ = ':';
1040610398
*(*d)++ = ':';
10407-
s += 2;
10399+
s += (*s == ':') ? 2 : 1;
1040810400
}
1040910401
else /* None of the above means have come to the end of any
1041010402
identifier*/

0 commit comments

Comments
 (0)