It is more cost-effective to directly assign tokenAddresses
to s_collateralTokens
.
Saving on gas based on the number of elements in tokenAddresses
: (was measured without gas optimizer)
1 Element in tokenAddresses |
2 Elements in tokenAddresses |
3 Elements in tokenAddresses |
|
---|---|---|---|
gas saved | -178 | 119 | 416 |
If there is only one element in tokenAddresses
, this method would cost more because using one .push()
is cheaper than directly assigning the array. But after the first .push()
, each subsequent .push()
operation would incur an additional deployment gas cost of 297 gas for each additional element, if the array is not directly assigned. Therefore, even with only two elements, it is more cost-effective to directly assign the array.
Before:
After:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.