-
Notifications
You must be signed in to change notification settings - Fork 49
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
Reduced mload in PrizeSplit #228
Reduced mload in PrizeSplit #228
Conversation
@@ -132,8 +132,7 @@ abstract contract PrizeSplit is IPrizeSplit, Ownable { | |||
uint256 prizeSplitsLength = _prizeSplits.length; | |||
|
|||
for (uint8 index = 0; index < prizeSplitsLength; index++) { | |||
PrizeSplitConfig memory split = _prizeSplits[index]; | |||
_tempTotalPercentage = _tempTotalPercentage + split.percentage; | |||
_tempTotalPercentage = _tempTotalPercentage + _prizeSplits[index].percentage; |
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.
_tempTotalPercentage = _tempTotalPercentage + _prizeSplits[index].percentage; | |
_tempTotalPercentage += _prizeSplits[index].percentage; |
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'm actually not sure this is cheaper since _prizeSplits
is in storage, so each time we access _prizeSplits[index].percentage
, it will cost us 200 in gas.
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.
either way it's one word
@@ -132,8 +132,7 @@ abstract contract PrizeSplit is IPrizeSplit, Ownable { | |||
uint256 prizeSplitsLength = _prizeSplits.length; | |||
|
|||
for (uint8 index = 0; index < prizeSplitsLength; index++) { | |||
PrizeSplitConfig memory split = _prizeSplits[index]; | |||
_tempTotalPercentage = _tempTotalPercentage + split.percentage; | |||
_tempTotalPercentage = _tempTotalPercentage + _prizeSplits[index].percentage; |
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'm actually not sure this is cheaper since _prizeSplits
is in storage, so each time we access _prizeSplits[index].percentage
, it will cost us 200 in gas.
36ca245
to
4e1d565
Compare
Issue: code-423n4/2021-10-pooltogether-findings#40