perf(transformer/refresh): RefreshIdentifierResolver::parse search string for . only once#10719
Conversation
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. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #10719 will not alter performanceComparing Summary
|
| 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)); | ||
| }; |
There was a problem hiding this comment.
Just curious, is there a way to get the second part first?
There was a problem hiding this comment.
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.
Merge activity
|
b02d103 to
9e557cf
Compare
19cd42a to
a1d2b81
Compare
a1d2b81 to
441d6b8
Compare
…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('.')`.
441d6b8 to
b57f2e8
Compare

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