perf: avoid extra Vec allocation in split_structs#9471
Open
Galoretka wants to merge 2 commits intostarkware-libs:mainfrom
Open
perf: avoid extra Vec allocation in split_structs#9471Galoretka wants to merge 2 commits intostarkware-libs:mainfrom
Galoretka wants to merge 2 commits intostarkware-libs:mainfrom
Conversation
orizi
requested changes
Jan 13, 2026
Collaborator
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and made 1 comment.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @Galoretka).
crates/cairo-lang-lowering/src/optimizations/split_structs.rs line 177 at r1 (raw file):
ctx.var_remapper.renamed_vars.insert(*output, new_var).is_none() ) }
Suggestion:
for (output, new_var) in zip_eq(&stmt.outputs, &output_split.vars) {
assert!(
ctx.var_remapper.renamed_vars.insert(*output, new_var.clone()).is_none()
)
}
orizi
approved these changes
Jan 14, 2026
Collaborator
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Galoretka).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace output_split.vars.to_vec() in the StructDestructure handling with output_split.vars.iter().cloned() so we no longer allocate a temporary Vec just to iterate over it.
Type of change
Why is this change needed?
Avoid per-statement heap allocation in a hot optimization pass.