Issue | Instances | |
---|---|---|
[GAS-1] | Cache array length outside of loop | 3 |
[GAS-2] | Use != 0 instead of > 0 for unsigned integer comparison | 4 |
[GAS-3] | Don't initialize variables with default value | 5 |
[GAS-4] | Use shift Right/Left instead of division/multiplication if possible | 1 |
[GAS-5] | ++i costs less gas than i++ , especially when it's used in for -loops (--i /i-- too) |
7 |
If not cached, the solidity compiler will always read the length of the array during each iteration. That is, if it is a storage array, this is an extra sload operation (100 additional extra gas for each iteration except for the first) and if it is a memory array, this is an extra mload operation (3 additional gas for each iteration except for the first).
Instances (3):
File: libraries/JBIpfsDecoder.sol
47: for (uint256 i = 0; i < _source.length; ++i) {
74: for (uint256 i = 0; i < _input.length; i++) {
82: for (uint256 i = 0; i < _indices.length; i++) {
Instances (4):
File: JBTiered721Delegate.sol
226: if (_pricing.tiers.length > 0) _store.recordAddTiers(_pricing.tiers);
File: JBTiered721DelegateStore.sol
1181: if (_numerator - JBConstants.MAX_RESERVED_RATE * _numberReservedTokensMintable > 0)
File: abstract/JB721Delegate.sol
109: if (_data.tokenCount > 0) revert UNEXPECTED_TOKEN_REDEEMED();
File: libraries/JBIpfsDecoder.sol
55: while (carry > 0) {
Instances (5):
File: libraries/JBIpfsDecoder.sol
47: for (uint256 i = 0; i < _source.length; ++i) {
49: for (uint256 j = 0; j < digitlength; ++j) {
66: for (uint256 i = 0; i < _length; i++) {
74: for (uint256 i = 0; i < _input.length; i++) {
82: for (uint256 i = 0; i < _indices.length; i++) {
Instances (1):
File: libraries/JBBitmap.sol
74: return _index / 256;
Saves 5 gas per loop
Instances (7):
File: JBTiered721DelegateStore.sol
222: _tiers[_numberOfIncludedTiers++] = JB721Tier({
1041: numberOfBurnedFor[msg.sender][_tierId]++;
1043: _storedTierOf[msg.sender][_tierId].remainingQuantity++;
File: libraries/JBIpfsDecoder.sol
57: digitlength++;
66: for (uint256 i = 0; i < _length; i++) {
74: for (uint256 i = 0; i < _input.length; i++) {
82: for (uint256 i = 0; i < _indices.length; i++) {
Issue | Instances | |
---|---|---|
[NC-1] | constant s should be defined rather than using magic numbers |
1 |
Instances (1):
File: libraries/JBIpfsDecoder.sol
44: uint8[] memory digits = new uint8[](46); // hash size with the prefix