Skip to content

perf(estree/tokens): replace hash map with Vec#19718

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-21-perf_estree_tokens_replace_hash_map_with_vec_
Feb 25, 2026
Merged

perf(estree/tokens): replace hash map with Vec#19718
graphite-app[bot] merged 1 commit intomainfrom
om/02-21-perf_estree_tokens_replace_hash_map_with_vec_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 25, 2026

AST walk happens in source code order, so we don't need a hashmap for storing token kind overrides. We can instead use a Vec. The Vec gets filled in ascending order of span start, and then is consumed in the 2nd pass in ascending order as well.

Iterating over a Vec in first-to-last order is much cheaper than a series of hashmap lookups which have a scattered read pattern.

@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Feb 25, 2026
This was referenced Feb 25, 2026
Copy link
Member Author

overlookmotel commented Feb 25, 2026


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 February 25, 2026 17:02
Copilot AI review requested due to automatic review settings February 25, 2026 17:02
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Feb 25, 2026
@graphite-app graphite-app bot changed the base branch from om/02-21-perf_estree_tokens_replace_multiple_hash_sets_into_a_single_hash_map to graphite-base/19718 February 25, 2026 19:26
@overlookmotel overlookmotel force-pushed the om/02-21-perf_estree_tokens_replace_hash_map_with_vec_ branch from 05dc0d8 to 7ab438c Compare February 25, 2026 19:39
@overlookmotel overlookmotel changed the base branch from graphite-base/19718 to om/02-21-perf_estree_tokens_replace_multiple_hash_sets_into_a_single_hash_map February 25, 2026 19:40
@graphite-app graphite-app bot changed the base branch from om/02-21-perf_estree_tokens_replace_multiple_hash_sets_into_a_single_hash_map to graphite-base/19718 February 25, 2026 19:49
@graphite-app graphite-app bot force-pushed the graphite-base/19718 branch from 7577c8f to b9d2443 Compare February 25, 2026 19:56
@graphite-app graphite-app bot force-pushed the om/02-21-perf_estree_tokens_replace_hash_map_with_vec_ branch from 7ab438c to 6d1d3a3 Compare February 25, 2026 19:56
@graphite-app graphite-app bot changed the base branch from graphite-base/19718 to main February 25, 2026 19:57
@graphite-app graphite-app bot force-pushed the om/02-21-perf_estree_tokens_replace_hash_map_with_vec_ branch from 6d1d3a3 to 25bbf94 Compare February 25, 2026 19:57
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 25, 2026

Merge activity

AST walk happens in source code order, so we don't need a hashmap for storing token kind overrides. We can instead use a `Vec`. The `Vec` gets filled in ascending order of span start, and then is consumed in the 2nd pass in ascending order as well.

Iterating over a `Vec` in first-to-last order is much cheaper than a series of hashmap lookups which have a scattered read pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter-plugins Area - Linter JS plugins 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