perf(codegen): avoid allocation in PrivateIdentifier gen when not mangling#17395
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. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the code generation for private identifiers by avoiding unnecessary string allocation in the non-mangling case. Previously, the code always called into_compact_str() to create a new CompactStr, even when no mangling was needed.
Key changes:
- Refactored the
PrivateIdentifiergeneration logic to conditionally handle mangled vs. non-mangled cases - In the non-mangling case, the code now directly prints from the string slice without creating a
CompactStr - In the mangling case, the logic remains functionally equivalent with the same allocation behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #17395 will not alter performanceComparing Summary
Footnotes
|
00f9f8d to
834155b
Compare
Merge activity
|
…gling (#17395) we previously always called `into_compact_str` when not mangling. This is unneccessary as we can just print from the string slice. <img width="692" height="173" alt="Screenshot 2025-12-27 at 20 42 12" src="https://github.com/user-attachments/assets/30228700-ec47-4894-b73a-8117c7a02af3" />
834155b to
510ec00
Compare

we previously always called
into_compact_strwhen not mangling. This is unneccessary as we can just print from the string slice.