You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function _concatParams(
uintamount,
uint256[] calldataparams
) internalpurereturns (uint256[] memoryresult) {
uint256 length = params.length;
result =newuint256[](length +1);
result[0] = amount;
for (uint256 i =0; i < length; ) {
result[i +1] = params[i];
unchecked {
++i;
}
}
}
Description
It was identified that the for loops employed in the contracts can be gas
optimized by the following principles:
• Unnecessary reading of the array length on each iteration wastes gas.
• Loop counters do not need to be set to 0, since uint256 is already initialized to 0.
• It is also possible to further optimize loops by using unchecked loop index incrementing
and decrementing.
Recommendation
Consider changing to:
for (uint256 i; i < length; ) {
result[i +1] = params[i];
unchecked {
++i;
}
}
The text was updated successfully, but these errors were encountered:
Risk Level
Severity: Gas
Code Segment
Description
It was identified that the for loops employed in the contracts can be gas
optimized by the following principles:
• Unnecessary reading of the array length on each iteration wastes gas.
• Loop counters do not need to be set to 0, since uint256 is already initialized to 0.
• It is also possible to further optimize loops by using unchecked loop index incrementing
and decrementing.
Recommendation
Consider changing to:
The text was updated successfully, but these errors were encountered: