Skip to content

Commit b5b88ba

Browse files
committed
Potentially skip whitespace scanning for speed
1 parent a14431c commit b5b88ba

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

src/prism.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9894,17 +9894,12 @@ parser_lex(pm_parser_t *parser) {
98949894
// stores back to parser->current.end.
98959895
bool chomping = true;
98969896
while (parser->current.end < parser->end && chomping) {
9897-
{
9898-
static const uint8_t inline_whitespace[256] = {
9899-
[' '] = 1, ['\t'] = 1, ['\f'] = 1, ['\v'] = 1
9900-
};
9901-
const uint8_t *scan = parser->current.end;
9902-
while (scan < parser->end && inline_whitespace[*scan]) scan++;
9903-
if (scan > parser->current.end) {
9904-
parser->current.end = scan;
9905-
space_seen = true;
9906-
continue;
9907-
}
9897+
if (pm_char_is_inline_whitespace(*parser->current.end)) {
9898+
const uint8_t *scan = parser->current.end + 1;
9899+
while (scan < parser->end && pm_char_is_inline_whitespace(*scan)) scan++;
9900+
parser->current.end = scan;
9901+
space_seen = true;
9902+
continue;
99089903
}
99099904

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

0 commit comments

Comments
 (0)