fix(cheatcodes): avoid unnecessary clone in create_end when merging recorded account diffs #12571
+3
−3
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.
The recorded account diffs handling in create_end used a temporary borrow of pop()’s result and fell back to cloning the popped vector to return it to the stack. This introduces needless allocations and diverges from the ownership pattern used in call_end. The code now takes ownership of the popped vector (let Some(mut last_depth) = recorded_account_diffs_stack.pop()), performs the same updates, and either appends into the previous depth via append(&mut last_depth) or pushes last_depth back without cloning. This preserves behavior and ordering semantics while eliminating an unnecessary clone and aligning the implementation with call_end for consistency and performance.