The id variable in the SaleOrder struct is not needed by the contract so I recommend removing it. Removing it would reduce gas cost in some of the functions.
The ItemExists(uint256 id) is below. It checks the id but it does not need to.
/**
@dev Modifier to check whether Item sales exist.
*/
modifier ItemExists(uint256 id) {
require(
id < itemsForSale.length && itemsForSale[id].id == id,
"Could not find requested item"
);
_;
}
The ItemExists(uint256 id) modifier could be written like this instead:
The
id
variable in the SaleOrder struct is not needed by the contract so I recommend removing it. Removing it would reduce gas cost in some of the functions.The
ItemExists(uint256 id)
is below. It checks theid
but it does not need to.The
ItemExists(uint256 id)
modifier could be written like this instead:The other require statements that check
id
can be removed without affecting anything.