Skip to content

perf(parser): add Modifiers::get method#20741

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-23-perf_parser_add_modifiers_get_method
Mar 26, 2026
Merged

perf(parser): add Modifiers::get method#20741
graphite-app[bot] merged 1 commit intomainfrom
om/03-23-perf_parser_add_modifiers_get_method

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 25, 2026

Add a get method to Modifiers that does a fast bitflags check whether the modifier is present before doing slower iteration through the Vec<Modifier>. The fast path is always taken except when there's a syntax error (rare).

Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 25, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

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

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 25, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 25, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/03-23-perf_parser_add_modifiers_get_method (126134b) with om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ (6627f58)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ (e2043a2) during the generation of this report, so 8e7a5c6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel marked this pull request as ready for review March 25, 2026 15:51
Copilot AI review requested due to automatic review settings March 25, 2026 15:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a fast Modifiers::get accessor that first checks the precomputed ModifierKinds bitset before doing a linear scan, and updates a call site to use it when a span-bearing modifier reference is needed.

Changes:

  • Add Modifiers::get(kind) to return an Option<&Modifier> with a fast bitset pre-check.
  • Use Modifiers::get(ModifierKind::Declare) in class constructor parsing to avoid unconditional iteration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_parser/src/modifiers.rs Introduces Modifiers::get using the existing kinds bitset to gate the linear search.
crates/oxc_parser/src/js/class.rs Switches the declare-constructor diagnostic to use the new get helper.

@overlookmotel overlookmotel force-pushed the om/03-23-perf_parser_add_modifiers_get_method branch from 3e043d7 to c37d9b5 Compare March 25, 2026 19:01
@overlookmotel overlookmotel force-pushed the om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ branch from 0d54c06 to 6627f58 Compare March 25, 2026 19:01
@graphite-app graphite-app bot force-pushed the om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ branch from 6627f58 to 1858708 Compare March 25, 2026 19:12
@graphite-app graphite-app bot force-pushed the om/03-23-perf_parser_add_modifiers_get_method branch from c37d9b5 to 23bf3b1 Compare March 25, 2026 19:13
@overlookmotel overlookmotel force-pushed the om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ branch from 1858708 to e2043a2 Compare March 25, 2026 19:13
@overlookmotel overlookmotel force-pushed the om/03-23-perf_parser_add_modifiers_get_method branch from 23bf3b1 to 126134b Compare March 25, 2026 19:13
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Mar 26, 2026

Merge activity

@camc314 camc314 force-pushed the om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ branch from e2043a2 to 90f6820 Compare March 26, 2026 13:25
@graphite-app graphite-app bot added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Mar 26, 2026
@graphite-app graphite-app bot changed the base branch from om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ to graphite-base/20741 March 26, 2026 13:34
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 26, 2026 — with Graphite App
graphite-app bot pushed a commit that referenced this pull request Mar 26, 2026
Add a `get` method to `Modifiers` that does a fast bitflags check whether the modifier is present before doing slower iteration through the `Vec<Modifier>`. The fast path is always taken except when there's a syntax error (rare).
@graphite-app graphite-app bot force-pushed the om/03-23-perf_parser_add_modifiers_get_method branch from 126134b to 4689d0e Compare March 26, 2026 13:38
@graphite-app graphite-app bot changed the base branch from graphite-base/20741 to om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ March 26, 2026 13:39
Add a `get` method to `Modifiers` that does a fast bitflags check whether the modifier is present before doing slower iteration through the `Vec<Modifier>`. The fast path is always taken except when there's a syntax error (rare).
@graphite-app graphite-app bot force-pushed the om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ branch from 21f9a96 to 1830303 Compare March 26, 2026 13:42
@graphite-app graphite-app bot force-pushed the om/03-23-perf_parser_add_modifiers_get_method branch from 4689d0e to 511d5e5 Compare March 26, 2026 13:43
Base automatically changed from om/03-23-refactor_parser_rename_modifierkinds_empty_to_none_ to main March 26, 2026 13:48
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 26, 2026
@graphite-app graphite-app bot merged commit 511d5e5 into main Mar 26, 2026
28 checks passed
@graphite-app graphite-app bot deleted the om/03-23-perf_parser_add_modifiers_get_method branch March 26, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants