contracts icon indicating copy to clipboard operation
contracts copied to clipboard

Update Oracles.sol: Optimized gas

Open 0xScratch opened this issue 1 year ago • 0 comments

Aims for three main changes that saves gas for this smart contract:

  1. Using immutable for keccak variables rather than constant: This comment by one of Openzeppelin's contributors going to be useful here.
  2. Using internal functions for the modifiers which appears more than often: Some Modifiers do appear more than 2-3 times and this kind of increases the gas costs on deploy time..Thus internal functions do help. Again, this convo between two contributors of Openzeppelin is worthwhile here.
  3. Enhancing 'for' loops: These for loops have been improved by changing ++i to i++. Although, I really doubt that this change really gonna make any change in the gas costs..Cuz as per my past experiences, this 'for' loop change works better with solidity version 0.8. Will be worth it if there's might be an updation of solidity version in future. Still refer this

Thanks @tsudmi

0xScratch avatar Nov 21 '23 16:11 0xScratch