SidraChain / sidra-contracts

Genesis Smart Contracts for Sidra Chain
GNU General Public License v3.0
1.98k stars 603 forks source link

Update PoolAccessControl.sol: Reduced the usage of 'SLOAD' #17

Closed 0xScratch closed 1 year ago

0xScratch commented 1 year ago

When we use the opcode sload, which is used to read a value from storage or a state variable, it consumes more gas. This is because the EVM reduces gas costs when data is written to or read from storage. If we examine the for loops closely, we can see that each iteration reads data from storage, which results in a high gas cost for executing those loops. To optimize this, it is a good practice to store that value in a memory type variable. By doing this, the length of the mapping is only read once, which helps to save gas.

Thanks @noumanmhd

noumanmhd commented 1 year ago

@Aryan9592 Can we have a meeting? LinkedIn Thanks