IT COSTS MORE GAS TO INITIALIZE VARIABLES TO ZERO THAN TO LET THE DEFAULT OF ZERO BE APPLIED
File: contracts\Basket.sol:
43: for (uint256 i = 0; i < _tokens.length; i++) {
70: for (uint256 i = 0; i < _tokens.length; i++) {
93: for (uint256 i = 0; i < _tokens.length; i++) {
File: contracts\NibblVault.sol:
506: for (uint256 i = 0; i < _assetAddresses.length; i++) {
525: for (uint256 i = 0; i < _assets.length; i++) {
547: for (uint256 i = 0; i < _assets.length; i++) {
.LENGTH SHOULD NOT BE LOOKED UP IN EVERY LOOP OF A FOR-LOOP
Even memory arrays incur the overhead of bit tests and bit shifts to calculate the array length. Storage array length checks incur an extra Gwarmaccess (100 gas) PER-LOOP.
File: contracts\Basket.sol:
43: for (uint256 i = 0; i < _tokens.length; i++) {
70: for (uint256 i = 0; i < _tokens.length; i++) {
93: for (uint256 i = 0; i < _tokens.length; i++) {
File: contracts\NibblVault.sol:
506: for (uint256 i = 0; i < _assetAddresses.length; i++) {
525: for (uint256 i = 0; i < _assets.length; i++) {
547: for (uint256 i = 0; i < _assets.length; i++) {
Expressions for constant values such as a call to
keccak256()
, should useimmutable
rather thanconstant
Conditions for an Require statement that includes the && operator can be broken down into multiple require statements to conserve gas.
The receive function is not implemented
If the intention is for the Ether to be used, the function should call another function, otherwise it should revert
IT COSTS MORE GAS TO INITIALIZE VARIABLES TO ZERO THAN TO LET THE DEFAULT OF ZERO BE APPLIED
Even memory arrays incur the overhead of bit tests and bit shifts to calculate the array length. Storage array length checks incur an extra Gwarmaccess (100 gas) PER-LOOP.