Skip to content

perf(parser): optimize around parse_return_type#12095

Merged
Boshen merged 1 commit intooxc-project:mainfrom
ulrichstark:optimize-around-parse_return_type
Jul 7, 2025
Merged

perf(parser): optimize around parse_return_type#12095
Boshen merged 1 commit intooxc-project:mainfrom
ulrichstark:optimize-around-parse_return_type

Conversation

@ulrichstark
Copy link
Contributor

@ulrichstark ulrichstark commented Jul 6, 2025

  • Removed has_return_colon because having both return_type and has_return_colon on ArrowFunctionHead was redundant
  • Avoid redundant self.is_ts checks by moving only required ones to call site of parse_ts_return_type_annotation
  • Removed unnecessary parameters return_kind and is_type from parse_return_type and their corresponding checks

Benchmark results:

parser[react.development.js] : +0.15%
parser[binder.ts]            : +0.05%
parser[cal.com.tsx]          : +0.01%

I expected more improvements on the benchmarks, but less code is also worth the change on its own.

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Jul 6, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 6, 2025

CodSpeed Instrumentation Performance Report

Merging #12095 will not alter performance

Comparing ulrichstark:optimize-around-parse_return_type (cb0e2a3) with main (85ec382)

Summary

✅ 38 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Jul 7, 2025

@ulrichstark It seems like you are getting good with the codebase and the parser, may I invite you to work on the minifier as well? Contact me on discord if you are intrested, and I'll get you acquainted.

@Boshen Boshen merged commit 494c29d into oxc-project:main Jul 7, 2025
27 checks passed
@ulrichstark ulrichstark deleted the optimize-around-parse_return_type branch July 7, 2025 05:45
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.

2 participants