Closed juliangruber closed 1 year ago
test_GasSetScoresManyParticipants() (gas: -23870849 (-9.853%))
This tests 1k participants, called 100 times in succession. Apparently smaller types are only cheaper if they're aligned so that they consume less space together (eg in a struct). Otherwise, there's an overhead associated with smaller types, since computation is necessary after reading it, since multiple entries can fit into one slot (vs a uint256 consumes the whole slot)
uint256 is cheaper than uint64, this reduces cost by ~1.5%
See also https://www.linkedin.com/pulse/solidity-gas-golfing-1-uint8-vs-uint256-sudeep-sagar/
cc @AmeanAsad