Remove the named return variable to save 25 gas per function call.
There are 8 instances of this issue:
FILE: Marketplace/Marketplace.sol
148: function authRedeem(uint8 p, address u, uint256 m, address f, address t, uint256 a) public authorized(markets[p][u][m].zcToken) returns (uint256 underlyingAmount) {
Summary
++i
uses less gas compared toi++
uint8
incurs more gas overhead compared touint256
uint
Gas Optimizations
++i
uses less gas compared toi++
This is especially relevant for the use of
i++
infor
loops. This saves 6 gas per loop.There are 5 instances of this issue:
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L100
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L269
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L417-L419
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L510-L512
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L563-L565
uint8
,uint16
, incurs more gas overhead compared touint256
There are 7 instances of this issue:
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L35
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L37
https://github.com/code-423n4/2022-07-swivel/blob/main/Marketplace/MarketPlace.sol#L65
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/Creator.sol#L31
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/Creator.sol#L38
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L26
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L17
Use named return variable instead of using return
There are 2 instances of this issue:
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L697
https://github.com/code-423n4/2022-07-swivel/blob/main/Marketplace/MarketPlace.sol#L207
Named return variable is not used
Remove the named return variable to save 25 gas per function call.
There are 8 instances of this issue:
https://github.com/code-423n4/2022-07-swivel/blob/main/Marketplace/MarketPlace.sol#L148
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L43
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L52
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L61
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L70
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L79
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L88
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L98
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L124
Use != 0 instead of > 0 for a
uint
This saves 6 gas per instance.
There are 17 instances of this issue:
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L118
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L155
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L190
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L219
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L284
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L315
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L345
https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L380
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L54
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L59
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L86
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L93
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L123
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L158
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L165
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L181
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L184
https://github.com/code-423n4/2022-07-swivel/blob/main/VaultTracker/VaultTracker.sol#L222