-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: removes redundant for loop #2955
Conversation
WalkthroughWalkthroughThe update involves the removal of a loop from the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
ss, ok := pk.GetSubspace(c.Subspace) | ||
if !ok { | ||
return sdkerrors.Wrap(proposal.ErrUnknownSubspace, c.Subspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure that the performance improvement is significant and does not introduce any regressions, consider adding benchmarks or performance tests if not already present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need the two for loops here because the rule is that if one parameter change is blocked then all other changes are void.
That being said it might be fine because if we perform an Update
and later realise that one of the parameters is blocked, it should simply fail the transaction and not apply it to state.
Generally there are going to only be a few parameters that get changed in a single proposal so I don't think the optimisation provides much gains
I think this test covers that scenario but I agree, the optimization doesn't seem strictly necessary and IMO the code is a bit more readable with two for loops. |
Overview
There are two for loops that iterate over the same values. This small PR combines them into one.
Checklist