Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 14, 2025

Refactor. Shorten some ESTree serialization code by using let chains.

It may also be marginally faster, due to only fetching start in one place (first_stmt.span() should be branchless and just a couple of ops, as every struct has span field in same position).

@github-actions github-actions bot added A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Aug 14, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review August 14, 2025 20:19
Copilot AI review requested due to automatic review settings August 14, 2025 20:19
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 refactors the get_ts_start_span function in the AST serialization module to use Rust's let chains syntax for more concise code. The functionality remains identical while reducing code duplication.

Key changes:

  • Simplified nested if-let patterns using let chains
  • Eliminated duplicate variable assignments and return statements
  • Restructured control flow to use a single return point

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 Aug 14, 2025

CodSpeed Instrumentation Performance Report

Merging #13100 will not alter performance

Comparing 08-14-refactor_ast_shorten_serialize_code_using_let_chains (7b86340) with main (3048302)

Summary

✅ 34 untouched benchmarks

@overlookmotel
Copy link
Member Author

Small change, and I think I know the serialization code better than anyone, so merging without review.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
Copy link
Member Author

overlookmotel commented Aug 14, 2025

Merge activity

Refactor. Shorten some ESTree serialization code by using `let` chains.

It may also be marginally faster, due to only fetching `start` in one place (`first_stmt.span()` should be branchless and just a couple of ops, as every struct has `span` field in same position).
@graphite-app graphite-app bot force-pushed the 08-14-refactor_ast_shorten_serialize_code_using_let_chains branch from 421656f to 7b86340 Compare August 14, 2025 21:05
@graphite-app graphite-app bot merged commit 7b86340 into main Aug 14, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 08-14-refactor_ast_shorten_serialize_code_using_let_chains branch August 14, 2025 21:10
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants