Skip to content

Comments

perf(parser): optimize parse_simple_arrow_function_expression#13965

Merged
Boshen merged 1 commit intooxc-project:mainfrom
ulrichstark:speedup-parse_simple_arrow_function_expression
Sep 22, 2025
Merged

perf(parser): optimize parse_simple_arrow_function_expression#13965
Boshen merged 1 commit intooxc-project:mainfrom
ulrichstark:speedup-parse_simple_arrow_function_expression

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented Sep 21, 2025

The function now accepts IdentifierReference instead of Expression to make its implementation simpler and avoid one match. Also all code around self.ctx is removed because it wasn't needed. This results in less code and a speedup in parser benchmarks of around 1% on my device.

Copilot AI review requested due to automatic review settings September 21, 2025 10:27
@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Sep 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the parse_simple_arrow_function_expression function by changing its parameter type from Expression to IdentifierReference and removing unnecessary context management code. The changes simplify the implementation and improve parser performance by approximately 1%.

  • Refactored function signature to accept IdentifierReference directly instead of Expression
  • Removed redundant context management around self.ctx
  • Simplified parameter construction logic by eliminating pattern matching

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_parser/src/js/expression.rs Updated call site to pass identifier reference directly and reordered condition check
crates/oxc_parser/src/js/arrow.rs Refactored function signature, removed context management, and simplified parameter construction

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 21, 2025

CodSpeed Instrumentation Performance Report

Merging #13965 will not alter performance

Comparing ulrichstark:speedup-parse_simple_arrow_function_expression (636f02c) with main (0185984)

Summary

✅ 37 untouched

Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, codspeed shows 1% as well!

@Boshen
Copy link
Member

Boshen commented Sep 22, 2025

Nice!

@Boshen Boshen merged commit 035ea19 into oxc-project:main Sep 22, 2025
30 checks passed
@ulrichstark ulrichstark deleted the speedup-parse_simple_arrow_function_expression branch September 22, 2025 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants