OpenZeppelin / openzeppelin-contracts-upgradeable

Upgradeable variant of OpenZeppelin Contracts, meant for use in upgradeable contracts.
https://openzeppelin.com/contracts
MIT License
1k stars 436 forks source link

Gas optimization #186

Closed molly-ting closed 1 year ago

molly-ting commented 1 year ago

For two numbers a and b, if a is always larger than or equal to b, unchecking addition operations on b or subtraction operations on a can save some gases. Each item in _balances is smaller than _totalSupply. So unchecking addition operations on items in _balances can save some gases.

PR Checklist

Amxx commented 1 year ago

This is a duplicate of https://github.com/OpenZeppelin/openzeppelin-contracts/pull/4021.