refactor(parser): Consolidate export type lookahead() calls#11341
refactor(parser): Consolidate export type lookahead() calls#11341graphite-app[bot] merged 1 commit intomainfrom
lookahead() calls#11341Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
CodSpeed Instrumentation Performance ReportMerging #11341 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
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.
|
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. |
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~.
e1d8359 to
bfaa443
Compare
lookahead()with if conditions in the same match armnext_kindvariable so thattoken.kind()does not have to be called many timesBetter 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~.