Solidity Gas Optimization dynamic function execution

41 views Asked by At

Anyone know which is more efficient dynamic function execution

function push(
    History storage self,
    function(uint256, uint256) view returns (uint256) op,
    uint256 delta
) internal returns (uint256, uint256) {
    return push(self, op(latest(self), delta));
}

or using an enum

function push(
    History storage self,
    uint8 operation
    uint256 delta
) internal returns (uint256, uint256) {
      if(operation == 1) {
          return push(self, latest(self) + delta);
     }
    return push(self, latest(self) - delta);
}
0

There are 0 answers