Skip to content

Commit 6e85f9b

Browse files
committed
perf(scanner): tweaked token dispatch code
1 parent 609e318 commit 6e85f9b

File tree

4 files changed

+30
-3798
lines changed

4 files changed

+30
-3798
lines changed

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ src/token.ts
44
src/common.ts
55
src/chars.ts
66
src/scanner/charClassifier.ts
7-
src/unicode.ts
7+
src/scanner/unicode.ts
88
package-lock.json

scripts/generate-unicode.js

+4
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ if (require.main === module) {
186186
isLineTerminator: [[0x0d, 0x0a, 0x2028, 0x2029]],
187187
isWhiteSpace: [
188188
[
189+
0x0d,
190+
0x0a,
191+
0x2028,
192+
0x2029,
189193
0x00a0,
190194
0x1680,
191195
0x2000,

src/scanner/scan.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,16 @@ export function scan(
173173
parser.start = parser.index;
174174

175175
if (char > 0b00000000000000000000000001111110) {
176-
if ((char & ~0b00000000000000000000000000000001) === Chars.LineSeparator) {
177-
parser.offset = ++parser.index;
178-
parser.newLine = 1;
179-
parser.curLine++;
180-
lastIsCR = 0;
181-
continue;
182-
}
183-
184176
if (((unicodeLookup[(char >>> 5) + 104448] >>> char) & 31 & 1) !== 0) {
185177
parser.index++;
178+
179+
if ((char & ~0b00000000000000000000000000000001) === Chars.LineSeparator) {
180+
parser.offset = parser.index;
181+
parser.newLine = 1;
182+
parser.curLine++;
183+
lastIsCR = 0;
184+
}
185+
186186
continue;
187187
}
188188

0 commit comments

Comments
 (0)