Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.
/contracts/src/PuttyV2.sol#L556 for (uint256 i = 0; i < orders.length; i++) {
/contracts/src/PuttyV2.sol#L611 for (uint256 i = 0; i < assets.length; i++) {
/contracts/src/PuttyV2.sol#L627 for (uint256 i = 0; i < assets.length; i++) {
/contracts/src/PuttyV2.sol#L637 for (uint256 i = 0; i < floorTokens.length; i++) {
/contracts/src/PuttyV2.sol#L647 for (uint256 i = 0; i < assets.length; i++)
/contracts/src/PuttyV2.sol#L658 for (uint256 i = 0; i < floorTokens.length; i++) {
/contracts/src/PuttyV2.sol#L670 for (uint256 i = 0; i < whitelist.length; i++) {
/contracts/src/PuttyV2.sol#L728 for (uint256 i = 0; i < arr.length; i++) {
/contracts/src/PuttyV2.sol#L742 for (uint256 i = 0; i < arr.length; i++) {
short reason string can be used for saving more gas
Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.
/contracts/src/PuttyV2.sol#L297 "Wrong amount of floor tokenIds"
/contracts/src/PuttyV2.sol#L298 "Invalid floor tokens length"
/contracts/src/PuttyV2.sol#L405 "Wrong amount of floor tokenIds"
/contracts/src/PuttyV2.sol#L406 "Invalid floor tokens length"
/contracts/src/PuttyV2.sol#L481 "Must be exercised or expired"
/contracts/src/PuttyV2.sol#L765 "URI query for NOT_MINTED token"
Saving gas by removing = 0
This implementation code can be saving more gas by removing = 0, it because If a variable was not set/initialized, it is assumed to have default value to 0
change uint256 i = 0 into uint i for saving more gas
using this implementation can saving more gas for each loops.
/contracts/src/PuttyV2.sol#L556 for (uint256 i = 0; i < orders.length; i++) {
/contracts/src/PuttyV2.sol#L611 for (uint256 i = 0; i < assets.length; i++) {
/contracts/src/PuttyV2.sol#L627 for (uint256 i = 0; i < assets.length; i++) {
/contracts/src/PuttyV2.sol#L637 for (uint256 i = 0; i < floorTokens.length; i++) {
/contracts/src/PuttyV2.sol#L647 for (uint256 i = 0; i < assets.length; i++)
/contracts/src/PuttyV2.sol#L658 for (uint256 i = 0; i < floorTokens.length; i++) {
/contracts/src/PuttyV2.sol#L670 for (uint256 i = 0; i < whitelist.length; i++) {
/contracts/src/PuttyV2.sol#L728 for (uint256 i = 0; i < arr.length; i++) {
/contracts/src/PuttyV2.sol#L742 for (uint256 i = 0; i < arr.length; i++) {
++i
thani++
for cost less gasUsing
i++
instead++i
for all the loops, the variable i is incremented using i++. It is known that implementation by using++i
costs less gas per iteration thani++
.Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.
= 0
This implementation code can be saving more gas by removing = 0, it because If a variable was not set/initialized, it is assumed to have default value to 0
uint256 i = 0
intouint i
for saving more gasusing this implementation can saving more gas for each loops.