mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
perf(parser): disambiguate single-identifier arrow heads (#28491)
Use bounded lookahead for `(identifier)` and `async(identifier)` to avoid speculative parameter parsing, preserving TypeScript return-type fallback. Validated parser conformance, bindings, and allocations. AI-assisted.
This commit is contained in:
1 parent
7f18c20029
commit
e1c9baf001
6 files changed
+30
-19
No files matched your search
@@ -161,7 +161,18 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
}
|
||||
Tristate::False
|
||||
}
|
||||
// If we have "(a," or "(a=" or "(a)" this *could* be an arrow function
|
||||
// A single identifier needs no speculative parameter parse. Keep `await`,
|
||||
// `yield`, and `this` on the existing contextual/error-recovery paths.
|
||||
// A TS return type can still be ambiguous with a conditional's colon.
|
||||
Kind::RParen if second.is_identifier() => {
|
||||
match self.lexer.next_token().kind() {
|
||||
Kind::Arrow => Tristate::True,
|
||||
Kind::Colon if self.is_ts => Tristate::Maybe,
|
||||
_ => Tristate::False,
|
||||
}
|
||||
}
|
||||
// If we have "(a," or "(a=" or a context-sensitive keyword in "(a)",
|
||||
// this *could* be an arrow function.
|
||||
Kind::Comma | Kind::Eq | Kind::RParen => Tristate::Maybe,
|
||||
// It is definitely not an arrow function
|
||||
_ => Tristate::False,
|
||||
|
||||
@@ -40,7 +40,7 @@ pdf.mjs:
|
||||
sys peak growth: 1156488 # 1.16 MB
|
||||
arena allocs: 21652
|
||||
arena reallocs: 402
|
||||
arena size: 11006048 # 11.01 MB
|
||||
arena size: 10987960 # 10.99 MB
|
||||
|
||||
antd.js:
|
||||
file size: 6686316 # 6.69 MB
|
||||
@@ -51,7 +51,7 @@ antd.js:
|
||||
sys peak growth: 13710144 # 13.71 MB
|
||||
arena allocs: 120676
|
||||
arena reallocs: 1889
|
||||
arena size: 114354248 # 114.35 MB
|
||||
arena size: 114187808 # 114.19 MB
|
||||
|
||||
binder.ts:
|
||||
file size: 193077 # 193.08 kB
|
||||
|
||||
@@ -40,7 +40,7 @@ pdf.mjs:
|
||||
sys peak growth: 3693355 # 3.69 MB
|
||||
arena allocs: 19582
|
||||
arena reallocs: 2574
|
||||
arena size: 5684472 # 5.68 MB
|
||||
arena size: 5666384 # 5.67 MB
|
||||
|
||||
antd.js:
|
||||
file size: 6686316 # 6.69 MB
|
||||
@@ -51,7 +51,7 @@ antd.js:
|
||||
sys peak growth: 19934725 # 19.93 MB
|
||||
arena allocs: 175842
|
||||
arena reallocs: 34169
|
||||
arena size: 43638784 # 43.64 MB
|
||||
arena size: 43472344 # 43.47 MB
|
||||
|
||||
binder.ts:
|
||||
file size: 193077 # 193.08 kB
|
||||
|
||||
@@ -33,25 +33,25 @@ RadixUIAdoptionSection.jsx:
|
||||
|
||||
pdf.mjs:
|
||||
file size: 567296 # 567.30 kB
|
||||
sys allocs: 67
|
||||
sys allocs: 61
|
||||
sys reallocs: 67
|
||||
sys deallocs: 67
|
||||
sys deallocs: 61
|
||||
sys alloc bytes: 24020 # 24.02 kB
|
||||
sys peak growth: 12140 # 12.14 kB
|
||||
arena allocs: 89436
|
||||
arena allocs: 89079
|
||||
arena reallocs: 5904
|
||||
arena size: 4510576 # 4.51 MB
|
||||
arena size: 4492488 # 4.49 MB
|
||||
|
||||
antd.js:
|
||||
file size: 6686316 # 6.69 MB
|
||||
sys allocs: 185
|
||||
sys allocs: 183
|
||||
sys reallocs: 221
|
||||
sys deallocs: 185
|
||||
sys alloc bytes: 109952 # 109.95 kB
|
||||
sys peak growth: 48264 # 48.26 kB
|
||||
arena allocs: 523271
|
||||
sys deallocs: 183
|
||||
sys alloc bytes: 94120 # 94.12 kB
|
||||
sys peak growth: 38896 # 38.90 kB
|
||||
arena allocs: 519986
|
||||
arena reallocs: 35629
|
||||
arena size: 30069720 # 30.07 MB
|
||||
arena size: 29903280 # 29.90 MB
|
||||
|
||||
binder.ts:
|
||||
file size: 193077 # 193.08 kB
|
||||
|
||||
@@ -40,7 +40,7 @@ pdf.mjs:
|
||||
sys peak growth: 832762 # 832.76 kB
|
||||
arena allocs: 0
|
||||
arena reallocs: 0
|
||||
arena size: 4510576 # 4.51 MB
|
||||
arena size: 4492488 # 4.49 MB
|
||||
|
||||
antd.js:
|
||||
file size: 6686316 # 6.69 MB
|
||||
@@ -51,7 +51,7 @@ antd.js:
|
||||
sys peak growth: 5441278 # 5.44 MB
|
||||
arena allocs: 0
|
||||
arena reallocs: 0
|
||||
arena size: 30069720 # 30.07 MB
|
||||
arena size: 29903280 # 29.90 MB
|
||||
|
||||
binder.ts:
|
||||
file size: 193077 # 193.08 kB
|
||||
|
||||
@@ -40,7 +40,7 @@ pdf.mjs:
|
||||
sys peak growth: 1610 # 1.61 kB
|
||||
arena allocs: 2
|
||||
arena reallocs: 0
|
||||
arena size: 4510600 # 4.51 MB
|
||||
arena size: 4492512 # 4.49 MB
|
||||
|
||||
antd.js:
|
||||
file size: 6686316 # 6.69 MB
|
||||
@@ -51,7 +51,7 @@ antd.js:
|
||||
sys peak growth: 1611 # 1.61 kB
|
||||
arena allocs: 2
|
||||
arena reallocs: 0
|
||||
arena size: 30069744 # 30.07 MB
|
||||
arena size: 29903304 # 29.90 MB
|
||||
|
||||
binder.ts:
|
||||
file size: 193077 # 193.08 kB
|
||||
|
||||
Reference in new issue
Block a user