refactor(lowering): extract rebuild_match_arm helper method#9709
refactor(lowering): extract rebuild_match_arm helper method#9709GarmashAlex wants to merge 2 commits intostarkware-libs:mainfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed all commit messages and made 2 comments.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on GarmashAlex).
crates/cairo-lang-lowering/src/utils.rs line 116 at r1 (raw file):
/// Rebuilds a match arm with renamed var and block ids. fn rebuild_match_arm(&mut self, arm: &MatchArm<'db>) -> MatchArm<'db> {
move helper to after usage function.
crates/cairo-lang-lowering/src/utils.rs line 141 at r1 (raw file):
function: stmt.function, inputs: stmt.inputs.iter().map(|v| self.map_var_usage(*v)).collect(), arms: stmt.arms.iter().map(|arm| self.rebuild_match_arm(arm)).collect(),
it seems the .iter().map(...).collect() should possibly be part of the helper function.
That's done |
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment and resolved 2 discussions.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on GarmashAlex).
crates/cairo-lang-lowering/src/utils.rs line 160 at r2 (raw file):
/// Rebuilds a match arm with renamed var and block ids. fn rebuild_match_arm(&mut self, arm: &MatchArm<'db>) -> MatchArm<'db> {
useless function. inline it.
Summary
Extract the common logic into a new rebuild_match_arm helper method to improve maintainability and reduce code duplication.
Type of change
Why is this change needed?
The rebuild_end function contained identical MatchArm rebuilding logic duplicated across all three MatchInfo variants (Extern, Enum, Value).