refactor(parser): make Modifier Copy#20824
refactor(parser): make Modifier Copy#20824overlookmotel wants to merge 1 commit intoom/03-28-perf_parser_defer_calculation_of_modifier_spansfrom
Modifier Copy#20824Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the parser’s Modifier value type to be trivially copyable now that it’s only 8 bytes, reducing unnecessary &Modifier passing and simplifying call sites in modifier validation and diagnostics paths.
Changes:
- Derive
CopyforModifierand changeModifier::spanto takeselfby value. - Update parser modifier-checking helpers and
verify_modifierscallback signatures to acceptModifierby value. - Adjust diagnostics call sites to pass owned
Modifiervalues instead of references.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/oxc_parser/src/modifiers.rs |
Makes Modifier Copy, updates span receiver and internal modifier validation APIs to take modifiers by value. |
crates/oxc_parser/src/js/module.rs |
Updates a diagnostics call site to pass an owned Modifier instead of &Modifier. |
crates/oxc_parser/src/diagnostics.rs |
Changes modifier-related diagnostic constructors to accept Modifier by value to match the new value semantics. |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Codspeed says (surprisingly) that this is a small perf regression. So closing. |

#20823 reduced
Modifierto 8 bytes. So it's now pointless passing around&Modifiers (also 8 bytes).Make
ModifierCopyand pass around ownedModifiers instead.