perf(parser): cleanup and optimize various parsing functions#14160
Merged
Boshen merged 2 commits intooxc-project:mainfrom Sep 27, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes various parsing functions by reducing unnecessary Option wrapping, eliminating redundant checks, and splitting functions for better performance. The changes focus on streamlining control flow and leveraging more efficient parsing patterns.
- Split
parse_normal_listinto breakable and non-breakable variants to avoid unnecessary Option handling - Refactored
parse_variable_declarationto acceptboolinstead of&Modifiersfor better performance - Separated break/continue statement parsing into dedicated functions and optimized various parsing helpers
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_parser/src/ts/types.rs | Simplified type literal parsing by removing Option wrapper |
| crates/oxc_parser/src/ts/statement.rs | Updated interface body parsing and variable declaration calls |
| crates/oxc_parser/src/modifiers.rs | Streamlined modifier construction and early return logic |
| crates/oxc_parser/src/js/statement.rs | Major refactoring of statement parsing with function splitting and optimization |
| crates/oxc_parser/src/js/declaration.rs | Simplified variable declaration parameter handling |
| crates/oxc_parser/src/js/class.rs | Updated class body parsing to use new breakable variant |
| crates/oxc_parser/src/cursor.rs | Added separate breakable/non-breakable list parsing functions |
Comments suppressed due to low confidence (1)
crates/oxc_parser/src/js/statement.rs:1
- This modifier verification logic has been moved here but appears to duplicate the verification that was previously done inside
parse_variable_declaration. Consider whether this verification should be consolidated in one location to avoid potential inconsistencies.
use oxc_allocator::{Box, Vec};
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #14160 will not alter performanceComparing Summary
Footnotes |
Member
|
Thank you! Less code, more performant! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
declare: boolinstead of&Modifiersavoid constructing empty ModifiersI hope these changes are not too much and therefore difficult to review. It's now less code with better performance. I was in the flow of refactoring and couldn't stop :)
Edit:
I don't see the improvements on Codspeed I'm seeing locally when running
cargo benchmark --bench parseragainst main... Feel free to close my PR if there are no verifiable performance improvements. My local output: