Skip to content

perf(transformer/refresh): RefreshIdentifierResolver::parse search string for . only once#10719

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once
Apr 30, 2025
Merged

perf(transformer/refresh): RefreshIdentifierResolver::parse search string for . only once#10719
graphite-app[bot] merged 1 commit intomainfrom
04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Apr 30, 2025

Small optimization. input.split('.') searches the string for ., so use the result of split instead of also calling input.contains('.').

@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Apr 30, 2025
@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Apr 30, 2025
Copy link
Member Author

overlookmotel commented Apr 30, 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 April 30, 2025 11:19
@overlookmotel overlookmotel requested a review from Dunqing as a code owner April 30, 2025 11:19
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 30, 2025

CodSpeed Instrumentation Performance Report

Merging #10719 will not alter performance

Comparing 04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once (b57f2e8) with main (9e557cf)

Summary

✅ 36 untouched benchmarks

Comment on lines 35 to +41
let mut parts = input.split('.');

let first_part = parts.next().unwrap();
let Some(second_part) = parts.next() else {
// Handle simple identifier reference
return Self::Identifier(ast.identifier_reference(SPAN, input));
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is there a way to get the second part first?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Split is an iterator, so you have to consume it in order. first_part is just a slice of input so it's not costly to generate.

I would also hope that compiler knows that Split always yields at least 1 item (even "".split('.') yields a single item ""), so it should be able to remove the .unwrap() in let first_part = parts.next().unwrap();. I don't know that for sure, though.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
Copy link
Member

Dunqing commented Apr 30, 2025

Merge activity

@graphite-app graphite-app bot changed the base branch from 04-29-perf_transformer_refresh_remove_temp_vec_ to graphite-base/10719 April 30, 2025 12:10
@graphite-app graphite-app bot force-pushed the graphite-base/10719 branch from b02d103 to 9e557cf Compare April 30, 2025 12:16
@graphite-app graphite-app bot force-pushed the 04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once branch from 19cd42a to a1d2b81 Compare April 30, 2025 12:16
@graphite-app graphite-app bot changed the base branch from graphite-base/10719 to main April 30, 2025 12:17
@graphite-app graphite-app bot force-pushed the 04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once branch from a1d2b81 to 441d6b8 Compare April 30, 2025 12:17
…string for `.` only once (#10719)

Small optimization. `input.split('.')` searches the string for `.`, so use the result of `split` instead of also calling `input.contains('.')`.
@graphite-app graphite-app bot force-pushed the 04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once branch from 441d6b8 to b57f2e8 Compare April 30, 2025 12:57
@graphite-app graphite-app bot merged commit b57f2e8 into main Apr 30, 2025
25 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 30, 2025
@graphite-app graphite-app bot deleted the 04-30-perf_transformer_refresh_refreshidentifierresolver_parse_search_string_for_._only_once branch April 30, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler 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