Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: simplify token context structure * add benchmark * perf: return a sub-state on tokenizer lookahead * Update packages/babel-parser/src/tokenizer/index.js Co-authored-by: Brian Ng <bng412@gmail.com> * Update packages/babel-parser/src/tokenizer/index.js Co-authored-by: Brian Ng <bng412@gmail.com> * remove irrelevant comment * fix: guard curPosition with isLookahead * add test cases Co-authored-by: Brian Ng <bng412@gmail.com>
- Loading branch information
1 parent
b1f57e5
commit acf2a10
Showing
10 changed files
with
684 additions
and
29 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/babel-parser/benchmark/many-arrow-function-flow-types/bench.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 "type A = " + "| (x) => void".repeat(length); | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [256, 512, 1024, 2048]) { | ||
const input = createInput(length); | ||
suite.add(`${name} ${length} arrow function types`, () => { | ||
implementation.parse(input, options); | ||
}); | ||
} | ||
} | ||
|
||
benchCases("baseline", baseline, { plugins: ["flow"] }); | ||
benchCases("current", current, { plugins: ["flow"] }); | ||
|
||
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
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
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
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
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
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/typescript/export/internal-comments/input.ts
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,2 @@ | ||
/*1*/ export /*2*/ { /*3*/ A /*4*/, /*5*/ B /*6*/ as /*7*/ C /*8*/ } /*9*/ from /*10*/ "foo"; | ||
/*1*/ export /*2*/ * /*3*/ from /*4*/ "foo" |
Oops, something went wrong.