Skip to content

perf(parser): check_identifier match on Kind not &str#11322

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-27-perf_parser_check_identifier_match_on_kind_not_str_
May 27, 2025
Merged

perf(parser): check_identifier match on Kind not &str#11322
graphite-app[bot] merged 1 commit intomainfrom
05-27-perf_parser_check_identifier_match_on_kind_not_str_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 27, 2025

Small optimization. ParserImpl::check_identifier check if the identifier is async or yield by comparing kind == Kind::Async instead of name == "async". Comparing Kinds is cheaper than string comparison.

Also:

  • Receive ctx as a parameter, to avoid parse_function_id having to temporarily overwrite self.ctx and then set it back again.
  • Don't take span as a parameter, because it can be obtained from self.cur_token().span(), and this is on a cold path.

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels May 27, 2025
Copy link
Member Author

overlookmotel commented May 27, 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.

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

@overlookmotel overlookmotel marked this pull request as ready for review May 27, 2025 12:34
@codspeed-hq
Copy link

codspeed-hq bot commented May 27, 2025

CodSpeed Instrumentation Performance Report

Merging #11322 will not alter performance

Comparing 05-27-perf_parser_check_identifier_match_on_kind_not_str_ (2372f00) with 05-27-perf_parser_avoid_work_in_parse_function_id_ (552a977)

Summary

✅ 38 untouched benchmarks

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label May 27, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 27, 2025

Merge activity

Small optimization. `ParserImpl::check_identifier` check if the identifier is `async` or `yield` by comparing `kind == Kind::Async` instead of `name == "async"`. Comparing `Kind`s is cheaper than string comparison.

Also:

* Receive `ctx` as a parameter, to avoid `parse_function_id` having to temporarily overwrite `self.ctx` and then set it back again.
* Don't take `span` as a parameter, because it can be obtained from `self.cur_token().span()`, and this is on a cold path.
@graphite-app graphite-app bot force-pushed the 05-27-perf_parser_avoid_work_in_parse_function_id_ branch from 41aebd6 to 552a977 Compare May 27, 2025 15:19
@graphite-app graphite-app bot force-pushed the 05-27-perf_parser_check_identifier_match_on_kind_not_str_ branch from a18b48b to 2372f00 Compare May 27, 2025 15:19
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 27, 2025
Base automatically changed from 05-27-perf_parser_avoid_work_in_parse_function_id_ to main May 27, 2025 15:27
@graphite-app graphite-app bot merged commit 2372f00 into main May 27, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 05-27-perf_parser_check_identifier_match_on_kind_not_str_ branch May 27, 2025 15:28
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