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

refactor(ast)!: store trivia comments in a sorted slice #4045

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Jul 3, 2024

This gets rid of TriviasMap, introducing SortedComments in order to store trivia comments in a sorted slice.

Closes: #4271

@github-actions github-actions bot added A-parser Area - Parser A-ast Area - AST labels Jul 3, 2024
Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing! Love the renaming to SortedComments.

@lucab lucab force-pushed the ups/ast-sorted-comments branch from db49452 to 309ba89 Compare July 3, 2024 15:43
@Boshen
Copy link
Member

Boshen commented Jul 3, 2024

You can run just ready or just just r to quickly verify everything.

Copy link

graphite-app bot commented Jul 3, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link

codspeed-hq bot commented Jul 3, 2024

CodSpeed Performance Report

Merging #4045 will improve performances by 5.57%

Comparing lucab:ups/ast-sorted-comments (57a812f) with main (09cc760)

Summary

⚡ 4 improvements
✅ 24 untouched benchmarks

Benchmarks breakdown

Benchmark main lucab:ups/ast-sorted-comments Change
semantic[antd.js] 13.1 s 12.4 s +5.56%
semantic[cal.com.tsx] 141.1 ms 135.5 ms +4.11%
semantic[checker.ts] 2.7 s 2.6 s +5.57%
semantic[pdf.mjs] 92.4 ms 88.2 ms +4.76%

@Boshen
Copy link
Member

Boshen commented Jul 3, 2024

No performance improvement from the parser benchmarks is somewhat expected.

Let me double check the semantic benchmark, I think I forgot to turn jsdoc parsing back on (which reads the comments).

@Boshen
Copy link
Member

Boshen commented Jul 3, 2024

I updated the benchmark on main, a quick rebase should reveal if there are any performance changes.

lucab added 3 commits July 3, 2024 18:43
This gets rid of `TriviasMap`, introducing `SortedComments` in order
to store trivia comments in a sorted slice.
@lucab lucab force-pushed the ups/ast-sorted-comments branch from 0ecde43 to 57a812f Compare July 3, 2024 16:43
@lucab
Copy link
Contributor Author

lucab commented Jul 3, 2024

Rebased, there are indeed some small perf improvements.

@Boshen Boshen merged commit e32b4bc into oxc-project:main Jul 3, 2024
26 checks passed
@lucab lucab deleted the ups/ast-sorted-comments branch July 4, 2024 08:55
@github-actions github-actions bot mentioned this pull request Jul 5, 2024
Boshen added a commit that referenced this pull request Jul 5, 2024
## [0.17.0] - 2024-07-05

- e32b4bc ast: [**BREAKING**] Store trivia comments in a sorted slice
(#4045) (Luca Bruno)

- 1df6ac0 ast: [**BREAKING**] Rename `visit_enum_memeber` to
`visit_ts_enum_member`. (#4000) (rzvxa)

- 4a0eaa0 ast: [**BREAKING**] Rename `visit_enum` to
`visit_ts_enum_declaration`. (#3998) (rzvxa)

- c98d8aa ast: [**BREAKING**] Rename `visit_arrow_expression` to
`visit_arrow_function_expression`. (#3995) (rzvxa)

### Features

- 1854a52 ast_codegen: Introduce the `#[span]` hint. (#4012) (rzvxa)
- 7538af1 ast_codegen: Add visit generator (#3954) (rzvxa)
- 7768d23 isolated-declarations: Support optional class methods (#4035)
(Egor Blinov)
- 0da9dfb minifier: Add constant folding to remove dead code (#4058)
(Boshen)

### Bug Fixes

- aaac2d8 codegen: Preserve parentheses from AST instead calculating
from operator precedence (#4055) (Boshen)
- 5e5b1b1 codegen: Correct accessibility emit for class
formal-parameters/methods/properties (#4042) (Egor Blinov)
- 7844734 codegen: Missing const keyword in TSTypeParamter (#4022)
(Dunqing)
- 6254a41 codegen: Missing TypeParamters in TSCallSignature (#4021)
(Dunqing)
- 3d29e9c isolated-declarations: Eliminate imports incorrectly when they
are used in `TSInferType` (#4043) (Dunqing)
- 02ea19a isolated-declarations: Should emit `export {}` when only
having `ImportDeclaration` (#4026) (Dunqing)
- 7c915f4 isolated-declarations: Binding elements with export should
report an error (#4025) (Dunqing)
- 05a047c isolated-declarations: Method following an abstract method
gets dropped (#4024) (Dunqing)
- c043bec isolated_declarations: Add mapped-type constraint to the scope
(#4037) (Egor Blinov)
- b007553 isolated_declarations: Fix readonly specifier on class
constructor params (#4030) (Egor Blinov)
- da62839 isolated_declarations: Inferring literal types for readonly
class fileds (#4027) (Egor Blinov)

### Refactor

- b51f75b ast_codegen: No longer outputs discard variable for empty
visitors. (#4008) (rzvxa)
- edb557c minifier: Add a folder struct for constant folding (#4057)
(Boshen)
- 243c9f3 parser: Use function instead of trait to parse list with rest
element (#4028) (Boshen)
- 1dacb1f parser: Use function instead of trait to parse delimited lists
(#4014) (Boshen)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
Boshen pushed a commit that referenced this pull request Jul 6, 2024
Follow on from #4045. Mark trivial functions related to `Trivias` as `#[inline]` and remove a couple of unnecessary `matches!` macro calls.
Boshen pushed a commit that referenced this pull request Jul 6, 2024
Follow-on from #4045. `.from_iter()` copies the `Vec` of comments into another `Vec` before converting to a boxed slice. This copy is unnecessary - just convert direct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-parser Area - Parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert TriviasMap (comments) into a Vec
2 participants