Skip to content

Commit 5985845

Browse files
committed
Scan all inline whitespace in one go
1 parent 1417634 commit 5985845

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/prism.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10100,7 +10100,11 @@ parser_lex(pm_parser_t *parser) {
1010010100
// token. Skip runs of inline whitespace in bulk to avoid per-character
1010110101
// stores back to parser->current.end.
1010210102
bool chomping = true;
10103-
while (parser->current.end < parser->end && chomping) {
10103+
while (chomping) {
10104+
/* Skip the run of inline whitespace in bulk, then decide what
10105+
* to do based on the first byte after it. Handling both in a
10106+
* single pass avoids re-entering the scan when the run was
10107+
* non-empty, which is the common case. */
1010410108
{
1010510109
static const uint8_t inline_whitespace[256] = {
1010610110
[' '] = 1, ['\t'] = 1, ['\f'] = 1, ['\v'] = 1
@@ -10110,8 +10114,8 @@ parser_lex(pm_parser_t *parser) {
1011010114
if (scan > parser->current.end) {
1011110115
parser->current.end = scan;
1011210116
space_seen = true;
10113-
continue;
1011410117
}
10118+
if (scan >= parser->end) break;
1011510119
}
1011610120

1011710121
switch (*parser->current.end) {

0 commit comments

Comments
 (0)