I am using solidity 0.8.10.
In my contract I have a state variable struct:
struct Product {
uint id_prod;
address payable producer_addr;
address payable owner_addr;
bool onSale;
}
and a state variable array of products:
Product[] public ProductList;
and a function that allows to modify the attributes of the product. Nothing really complex.
Considering the cost in deploying and using the contract, I think there are two ways of changing the attributes of the product.
Solution 1, by using a storage variable:
Product storage _product = ProductList[_id_product];
_product.owner_addr = payable(msg.sender);
_product.onSale = false;
Solution 2, without a storage variable:
ProductList[_id_product].owner_addr = payable(msg.sender);
ProductList[_id_product].onSale = false;
Which solution is the cheapest, cleanest, most advisable?