Skip to content

Commit 8fd4cbe

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 ce66c57 commit 8fd4cbe

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
@@ -10586,26 +10586,31 @@ S_parse_ident(pTHX_ const char *s, const char * const s_end,
1058610586
* for the subset before checking for the superset. */
1058710587
Size_t advance;
1058810588
if (is_utf8 && (advance = isIDFIRST_utf8_safe(s, s_end))) {
10589+
const char *this_start = s;
10590+
s += advance;
1058910591

1059010592
/* Find the end of the identifier by accumulating characters until
1059110593
* find a non-identifier character */
10592-
const char *t = s + advance;
10593-
while ((advance = isIDCONT_utf8_safe((const U8*) t,
10594-
(const U8*) s_end)))
10595-
{
10596-
t += advance;
10594+
while (s < s_end) {
10595+
advance = isIDCONT_utf8_safe((const U8*) s,
10596+
(const U8*) s_end);
10597+
if (advance == 0) { /* Not an identifier character */
10598+
break;
10599+
}
10600+
10601+
s += advance;
1059710602
}
1059810603

1059910604
/* Here we have found the end of the identifier */
10600-
Size_t this_length = t - s;
10605+
Size_t this_length = s - this_start;
10606+
1060110607
if (*d + this_length >= e) {
1060210608
goto too_long;
1060310609
}
1060410610

1060510611
/* And copy the whole thing in one operation */
10606-
Copy(s, *d, this_length, char);
10612+
Copy(this_start, *d, this_length, char);
1060710613
*d += this_length;
10608-
s = t;
1060910614
}
1061010615
else if ( isWORDCHAR_A(*s) ) {
1061110616

0 commit comments

Comments
 (0)