Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict TS try/catch logic to cases where backtracking is needed #327

Merged
merged 1 commit into from
Nov 5, 2018

Conversation

alangpierce
Copy link
Owner

Fixes #326

When porting some babel-parser changes, there was some code in TS parsing that
was unconditionally wrapping some parsing in a try/catch, but actually it only
cared about cases that started with <. By inverting the logic a little, we
avoid having to throw and catch an exception in the common case of parsing,
which was dramatically slowing down TypeScript parsing.

Fixes #326

When porting some babel-parser changes, there was some code in TS parsing that
was unconditionally wrapping some parsing in a try/catch, but actually it only
cared about cases that started with `<`. By inverting the logic a little, we
avoid having to throw and catch an exception in the common case of parsing,
which was dramatically slowing down TypeScript parsing.
@codecov-io
Copy link

codecov-io commented Nov 5, 2018

Codecov Report

Merging #327 into master will decrease coverage by 76.62%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #327       +/-   ##
=========================================
- Coverage   76.62%     0%   -76.63%     
=========================================
  Files          41     23       -18     
  Lines        5458   2074     -3384     
  Branches     1279    605      -674     
=========================================
- Hits         4182      0     -4182     
- Misses        900   2074     +1174     
+ Partials      376      0      -376
Impacted Files Coverage Δ
src/parser/plugins/jsx/xhtml.ts 0% <0%> (-100%) ⬇️
src/parser/tokenizer/state.ts 0% <0%> (-100%) ⬇️
src/util/isIdentifier.ts 0% <0%> (-100%) ⬇️
src/util/getNonTypeIdentifiers.ts 0% <0%> (-100%) ⬇️
src/parser/traverser/index.ts 0% <0%> (-100%) ⬇️
src/parser/traverser/lval.ts 0% <0%> (-95.95%) ⬇️
src/parser/util/identifier.ts 0% <0%> (-92%) ⬇️
src/parser/traverser/base.ts 0% <0%> (-91.9%) ⬇️
src/parser/plugins/jsx/index.ts 0% <0%> (-89.12%) ⬇️
src/computeSourceMap.ts 0% <0%> (-88.89%) ⬇️
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 951679d...e5de588. Read the comment docs.

@alangpierce
Copy link
Owner Author

Looks like something is buggy about coverage. I confirmed that it isn't related to this PR and filed as #329

@alangpierce alangpierce merged commit 52f92bc into master Nov 5, 2018
@alangpierce alangpierce deleted the fix-ts-parse-perf-regression branch November 5, 2018 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants