Which of these two implementations can save gas costs
Implementation 1: I’ll have to pay extra gas for reserving the memory and but then don’t need to read from the storage for require statements.
function claimSpam(bytes32 _msgFinalHash) public{
Spam memory spam = spams[_msgFinalHash];
require(spam.recipient == msg.sender, "This Spam want sent to you, couldnt be deleted");
require(block.timestamp >spam.createdTime + 1 days, "You can claim the value attached to a spam at least after a day");
SortedLinkedList.remove(users[msg.sender].spamArray, _msgFinalHash);
balances[msg.sender] += spam.value;
}
VS
function claimSpam(bytes32 _msgFinalHash) public{
require(spams[_msgFinalHash].recipient == msg.sender, "This Spam want sent to you, couldnt be deleted");
require(block.timestamp >spams[_msgFinalHash].createdTime + 1 days, "You can claim the value attached to a spam at least after a day");
SortedLinkedList.remove(users[msg.sender].spamArray, _msgFinalHash);
balances[msg.sender] += spams[_msgFinalHash].value;
}