Skip to content

Commit d35940a

Browse files
committed
S_scan_ident: Collapse two loops
By setting a variable in advance, we can merge two loops into one.
1 parent 02ae424 commit d35940a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

toke.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10852,22 +10852,16 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, U32 flags)
1085210852
* encoded in UTF-8 or not, we can use the foo_A macros below and '\0' and
1085310853
* '{' without knowing if is UTF-8 or not. */
1085410854

10855+
STRLEN advance = 1;
1085510856
if ( s < PL_bufend
1085610857
&& ( isGRAPH_A(*s)
10857-
|| (is_utf8 ? isIDFIRST_utf8_safe(s, PL_bufend)
10858+
|| (is_utf8 ? (advance = isIDFIRST_utf8_safe(s, PL_bufend))
1085810859
: (isGRAPH_L1(*s) && LIKELY((U8) *s != SHY_NATIVE)))))
1085910860
{
10860-
if (is_utf8) {
10861-
const STRLEN skip = UTF8SKIP(s);
1086210861
STRLEN i;
10863-
d[skip] = '\0';
10864-
for ( i = 0; i < skip; i++ )
10862+
d[advance] = '\0';
10863+
for ( i = 0; i < advance; i++ )
1086510864
d[i] = *s++;
10866-
}
10867-
else {
10868-
*d = *s++;
10869-
d[1] = '\0';
10870-
}
1087110865
}
1087210866

1087310867
/* 'd' has not been advanced, but if 's' pointed to a legal identifier

0 commit comments

Comments
 (0)