Skip to content

Commit fff0b52

Browse files
committed
S_parse_ident: Restructure loop
The loop is refactored to eliminate an assignment at the end, and I think it is slightly clearer. But more importantly, it prepares for future commits. There is some extra indentation that will make sense when those commits are done
1 parent a9ebc12 commit fff0b52

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

toke.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10345,26 +10345,31 @@ S_parse_ident(pTHX_ const char *s, const char * const s_end,
1034510345
* for the subset before checking for the superset. */
1034610346
Size_t advance;
1034710347
if (is_utf8 && (advance = isIDFIRST_utf8_safe(s, s_end))) {
10348+
const char *this_start = s;
10349+
s += advance;
1034810350

1034910351
/* Find the end of the identifier by accumulating characters until
1035010352
* find a non-identifier character */
10351-
const char *t = s + advance;
10352-
while ((advance = isIDCONT_utf8_safe((const U8*) t,
10353-
(const U8*) s_end)))
10354-
{
10355-
t += advance;
10353+
while (s < s_end) {
10354+
advance = isIDCONT_utf8_safe((const U8*) s,
10355+
(const U8*) s_end);
10356+
if (advance == 0) { /* Not an identifier character */
10357+
break;
10358+
}
10359+
10360+
s += advance;
1035610361
}
1035710362

1035810363
/* Here we have found the end of the identifier */
10359-
Size_t this_length = t - s;
10364+
Size_t this_length = s - this_start;
10365+
1036010366
if (*d + this_length >= e) {
1036110367
goto too_long;
1036210368
}
1036310369

1036410370
/* And copy the whole thing in one operation */
10365-
Copy(s, *d, this_length, char);
10371+
Copy(this_start, *d, this_length, char);
1036610372
*d += this_length;
10367-
s = t;
1036810373
}
1036910374
else if ( isWORDCHAR_A(*s) ) {
1037010375

0 commit comments

Comments
 (0)