perf(parser): reduce Kind to ModifierKind conversions in eat_modifiers_before_declaration#20820
Conversation
There was a problem hiding this comment.
Pull request overview
Optimizes oxc_parser modifier parsing by avoiding redundant Kind -> ModifierKind conversions in eat_modifiers_before_declaration, keeping the same lookahead-based correctness checks while reducing work on the hot path.
Changes:
- Replace
at_modifier()+modifier()flow with a singleget_modifier()that returnsOption<ModifierKind>. - Construct
Modifierdirectly from the already-convertedModifierKind. - Rename/update the lookahead worker accordingly.
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
…ifiers_before_declaration` (#20820) Small perf optimization. `eat_modifiers_before_declaration` was converting `Kind` to `ModifierKind` twice - once in `self.at_modifier()` (`kind.is_modifier_kind()`), and then again in `self.modifier()` (`ModifierKind::try_from(kind)`). Instead, convert only once. +0.1% improvement on most parser benchmarks.
ebbdd03 to
ccbd3e9
Compare
…ifiers_before_declaration` (#20820) Small perf optimization. `eat_modifiers_before_declaration` was converting `Kind` to `ModifierKind` twice - once in `self.at_modifier()` (`kind.is_modifier_kind()`), and then again in `self.modifier()` (`ModifierKind::try_from(kind)`). Instead, convert only once. +0.1% improvement on most parser benchmarks.
ccbd3e9 to
eb02c88
Compare

Small perf optimization.
eat_modifiers_before_declarationwas convertingKindtoModifierKindtwice - once inself.at_modifier()(kind.is_modifier_kind()), and then again inself.modifier()(ModifierKind::try_from(kind)).Instead, convert only once.
+0.1% improvement on most parser benchmarks.