Skip to content

Commit

Permalink
Report for issue #447 updated by __141345__
Browse files Browse the repository at this point in the history
  • Loading branch information
code423n4 committed Sep 15, 2022
1 parent 0802556 commit 47c0cdc
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions data/__141345__-G.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,6 @@ src/lib/token/ERC721Votes.sol
mapping(address => mapping(uint256 => Checkpoint)) internal checkpoints;
```

#### Variables referred multiple times can be cached in local memory

Each storage read uses opcode `sload` which costs 100 gas (warm access), while memory read uses `mload` which only cost 3 gas. ([reference](https://ethereum.org/en/developers/docs/evm/opcodes/))
Even for a memory struct variable, the member variable access still has overhead. It can be saved further by caching the final result.


`proposal.proposer` can be cached.
src/governance/governor/Governor.sol
```solidity
```

#### Use bit shift instead of power operation or * 2, / 2

Expand All @@ -215,4 +204,3 @@ Change the above to
```

The demo of the gas comparison can be seen [here](https://github.com/Flame57/gas_demo/blob/main/bit_shift.sol).

0 comments on commit 47c0cdc

Please sign in to comment.