Skip to content

Commit

Permalink
Optimize gas fee (#401)
Browse files Browse the repository at this point in the history
* optimize gas fee

* remove unchecked iterator increments

* formatting my code

* format my code

---------

Co-authored-by: HuyHuynh3103 <1917420@student.hcmus.edu.vn>
  • Loading branch information
huyhuynh3103 and HuyHuynh3103 committed Mar 18, 2023
1 parent 96ad6ca commit 66c0ec4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/src/v0.1/VRFCoordinator.sol
Expand Up @@ -162,9 +162,10 @@ contract VRFCoordinator is
revert NoSuchProvingKey(kh);
}
delete s_provingKeys[kh];
for (uint256 i = 0; i < s_provingKeyHashes.length; i++) {
uint256 provingKeyHashesLength = s_provingKeyHashes.length;
for (uint256 i; i < provingKeyHashesLength; i++) {
if (s_provingKeyHashes[i] == kh) {
bytes32 last = s_provingKeyHashes[s_provingKeyHashes.length - 1];
bytes32 last = s_provingKeyHashes[provingKeyHashesLength - 1];
// Copy last element and overwrite kh to be deleted with it
s_provingKeyHashes[i] = last;
s_provingKeyHashes.pop();
Expand Down

0 comments on commit 66c0ec4

Please sign in to comment.