Skip to content

refactor(parser): Consolidate export type lookahead() calls#11341

Merged
graphite-app[bot] merged 1 commit intomainfrom
r/parser-module-type
May 28, 2025
Merged

refactor(parser): Consolidate export type lookahead() calls#11341
graphite-app[bot] merged 1 commit intomainfrom
r/parser-module-type

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented May 28, 2025

  • Merged separate lookahead() with if conditions in the same match arm
  • Keep next_kind variable so that token.kind() does not have to be called many times

Better than do nothing?

Or, I don't know much about it, but maybe Rust is smart enough to optimize this...? In that case, feel free to close this~.

@graphite-app
Copy link
Contributor

graphite-app bot commented May 28, 2025

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.

@github-actions github-actions bot added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels May 28, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 28, 2025

CodSpeed Instrumentation Performance Report

Merging #11341 will not alter performance

Comparing r/parser-module-type (bfaa443) with main (bbb7eb1)

Summary

✅ 38 untouched benchmarks

@leaysgur leaysgur marked this pull request as ready for review May 28, 2025 04:43
Copilot AI review requested due to automatic review settings May 28, 2025 04:43
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 parser logic for handling export type declarations by consolidating the lookahead calls.

  • Consolidates separate lookahead checks into one using a checkpoint, bump, and rewind sequence.
  • Refactors the logic for determining the import or export kind by replacing redundant token calls with a single next_kind variable.

@Boshen Boshen requested a review from camchenry May 28, 2025 05:14
@overlookmotel
Copy link
Member

I don't know if compiler is smart enough to combine these 2 branches itself, but I wouldn't rely on it. It's quite complicated for it to reason about. So I'd say not relying on the compiler and doing it manually as you have here is probably preferable.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 28, 2025
Copy link
Member

Boshen commented May 28, 2025

Merge activity

- Merged separate `lookahead()` with if conditions in the same match arm
- Keep `next_kind` variable so that `token.kind()` does not have to be called many times

Better than do nothing?

Or, I don't know much about it, but maybe Rust is smart enough to optimize this...? In that case, feel free to close this~.
@graphite-app graphite-app bot force-pushed the r/parser-module-type branch from e1d8359 to bfaa443 Compare May 28, 2025 13:29
@graphite-app graphite-app bot merged commit bfaa443 into main May 28, 2025
25 checks passed
@graphite-app graphite-app bot deleted the r/parser-module-type branch May 28, 2025 13:36
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser 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.

5 participants