Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: minimize identifier lookahead when parsing let (#13328)
- Loading branch information
Showing
8 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/babel-parser/benchmark/many-let-declarations/10-length-binding.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Benchmark from "benchmark"; | ||
import baseline from "@babel-baseline/parser"; | ||
import current from "../../lib/index.js"; | ||
import { report } from "../util.mjs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
function createInput(length) { | ||
return "{ let foecnatsni };".repeat(length); | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [64, 128, 256, 512]) { | ||
const input = createInput(length); | ||
suite.add(`${name} ${length} let and length-10 binding identifiers`, () => { | ||
implementation.parse(input, options); | ||
}); | ||
} | ||
} | ||
|
||
benchCases("baseline", baseline); | ||
benchCases("current", current); | ||
|
||
suite.on("cycle", report).run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/let/let-declaration-in-escape-id/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let in\u0061; |
30 changes: 30 additions & 0 deletions
30
packages/babel-parser/test/fixtures/es2015/let/let-declaration-in-escape-id/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":12,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":12}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":12,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":12},"identifierName":"ina"}, | ||
"name": "ina" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/let/let-declaration-in-non-BMP/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let in饾惉饾惌饾悮饾惂饾悳饾悶饾惃饾悷; |
30 changes: 30 additions & 0 deletions
30
packages/babel-parser/test/fixtures/es2015/let/let-declaration-in-non-BMP/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":23,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":23}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":22,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":22}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":22,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":22},"identifierName":"in饾惉饾惌饾悮饾惂饾悳饾悶饾惃饾悷"}, | ||
"name": "in饾惉饾惌饾悮饾惂饾悳饾悶饾惃饾悷" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/let/let-declaration-non-BMP-identifier/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let 饾悽饾惂; |
30 changes: 30 additions & 0 deletions
30
...ages/babel-parser/test/fixtures/es2015/let/let-declaration-non-BMP-identifier/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8},"identifierName":"饾悽饾惂"}, | ||
"name": "饾悽饾惂" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |