perf(parser): defer calculation of Modifier spans#20823
perf(parser): defer calculation of Modifier spans#20823graphite-app[bot] merged 1 commit intomainfrom
Modifier spans#20823Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes modifier handling in oxc_parser by deferring full Span reconstruction for modifiers until it’s actually needed (primarily diagnostics), reducing work on the hot parsing path.
Changes:
- Replace stored
Modifier.span: SpanwithModifier.span_start: u32and reconstruct spans lazily viaModifier::span(). - Update modifier parsing/collection to record only start offsets.
- Update diagnostics and call sites to use
modifier.span()instead of the removedmodifier.spanfield.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/oxc_parser/src/modifiers.rs |
Changes Modifier to store only span_start, adds lazy span() reconstruction, and updates modifier parsing/collection paths accordingly. |
crates/oxc_parser/src/js/module.rs |
Adjusts duplicate export-modifier diagnostic construction to match the new Modifier::new(span_start, kind) API. |
crates/oxc_parser/src/js/class.rs |
Updates diagnostics call sites to use modifier.span() accessor. |
crates/oxc_parser/src/diagnostics.rs |
Updates modifier-related diagnostics to label using modifier.span() instead of a stored span field. |
Merge activity
|
26f05f9 to
b3ca6a4
Compare
Small perf optimization. The `Span` of a modifier is only required when an error is raised (cold path). Don't eagerly calculate and store the full span in `Modifier`, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).
e6c5fb8 to
45d7efb
Compare
b3ca6a4 to
2e7e6bd
Compare
Small perf optimization. The `Span` of a modifier is only required when an error is raised (cold path). Don't eagerly calculate and store the full span in `Modifier`, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).
45d7efb to
055a7ac
Compare

Small perf optimization.
The
Spanof a modifier is only required when an error is raised (cold path).Don't eagerly calculate and store the full span in
Modifier, only store the span's start. Calculate the span's end lazily only when it's needed (which it only is if source contains syntax errors).