This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 664
refactor(rome_js_formatter): avoid snapshot when formatting skipped token trivia #2683
Merged
Conversation
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
MichaReiser
force-pushed
the
refactor/skipped-trivia-formatting
branch
from
June 8, 2022 09:52
691dea5
to
a83af32
Compare
MichaReiser
force-pushed
the
refactor/skipped-trivia-formatting
branch
from
June 8, 2022 09:54
a83af32
to
02eb10b
Compare
Deploying with Cloudflare Pages
|
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
MichaReiser
force-pushed
the
refactor/skipped-trivia-formatting
branch
from
June 8, 2022 10:09
02eb10b
to
9245d79
Compare
ematipico
changed the title
refactor(formatter): Avoid snapshot when formatting skipped token trivia
refactor(rom_formatter): avoid snapshot when formatting skipped token trivia
Jun 8, 2022
ematipico
changed the title
refactor(rom_formatter): avoid snapshot when formatting skipped token trivia
refactor(rome_js_formatter): avoid snapshot when formatting skipped token trivia
Jun 8, 2022
!bench_formatter |
MichaReiser
force-pushed
the
refactor/skipped-trivia-formatting
branch
from
June 8, 2022 11:53
9245d79
to
648cdb9
Compare
Formatter Benchmark Results
|
ematipico
approved these changes
Jun 8, 2022
leops
approved these changes
Jun 9, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This removes the need to take a snapshot before formatting leading trivia by collecting the comments into a
Vec
. The performance characteristics of the new implementation should be similar to the old because it removes the need to allocate a temporaryVecBuffer
to be able to reverse the written comments in the end.I find this solution slightly easier to reason about and results in slightly less code:
Before:
After:
FormatLeadingTrivia
no longer shows up.It also gives us the option to use a
SmallVec
to store comments if profiling shows that this is beneficial.Test Plan
cargo test