Let's say I have a view
function that accesses a storage
mapping like so:
function performCalculation(uint256 _id) public view returns(uint256) {
uint256 memory someValue = someMapping[_id];
return someValue - 10;
}
And I have another function which also accesses that same value:
function someFunction(uint256 _id) external {
uint256 storage someValue = someMapping[_id];
// do something
}
If inside someFunction
I needed to perform the same calculation that performCalculation
does, would calling performCalculation
from someFunction
use more gas as it is accessing storage again? Would the better solution be to just do the same calculation inline using the someValue
from someFunction
?