perf(parser): add Modifiers::get method#20741
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
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 anOption<&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. |
3e043d7 to
c37d9b5
Compare
0d54c06 to
6627f58
Compare
6627f58 to
1858708
Compare
c37d9b5 to
23bf3b1
Compare
1858708 to
e2043a2
Compare
23bf3b1 to
126134b
Compare
Merge activity
|
e2043a2 to
90f6820
Compare
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).
126134b to
4689d0e
Compare
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).
21f9a96 to
1830303
Compare
4689d0e to
511d5e5
Compare

Add a
getmethod toModifiersthat does a fast bitflags check whether the modifier is present before doing slower iteration through theVec<Modifier>. The fast path is always taken except when there's a syntax error (rare).