Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #7

Closed
code423n4 opened this issue Jun 21, 2022 · 3 comments
Closed

Gas Optimizations #7

code423n4 opened this issue Jun 21, 2022 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) invalid This doesn't seem right

Comments

@code423n4
Copy link
Contributor

For-Loop :

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L506
https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L525
https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L547
1 - An array’s length should be cached to save gas in for-loops
Reading array length at each iteration of the loop takes 6 gas

2 - Increments can be unchecked and ++i costs less gas compared to i++
The code would go to :

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 21, 2022
code423n4 added a commit that referenced this issue Jun 21, 2022
@mundhrakeshav mundhrakeshav added the duplicate This issue or pull request already exists label Jun 23, 2022
@mundhrakeshav
Copy link
Collaborator

Duplicate of issue 6

@HardlyDifficult
Copy link
Collaborator

Merging with #10

@JeeberC4 JeeberC4 added the invalid This doesn't seem right label Jul 4, 2022
@JeeberC4
Copy link

JeeberC4 commented Jul 4, 2022

Warden submitted multiple Gas Optimizations. Will not be judged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

5 participants