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 #20

Open
code423n4 opened this issue Jul 14, 2022 · 0 comments
Open

Gas Optimizations #20

code423n4 opened this issue Jul 14, 2022 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

dnssec-oracle/BytesUtils.sol

  • L116/126 - An array.length variable could be generated in memory and used directly, this would generate a lower gas cost.

  • L56/264/266 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L266/271/292/313 - Instead of i++ or i + 1 or i--, it is less expensive to do --i or ++i

dnssec-oracle/DNSSECImpl.sol

  • L93/186/187 - You could generate a variable in memory of array.length and use that variable directly, this would generate a lower gas cost.

  • L93 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L93 - Instead of i++ or i + 1 or i--, it is less expensive to do --i or ++i

dnssec-oracle/RRUtils.sol

  • L39/40 - It is not necessary to create a variable if it will only be used once within the function.

  • L50/181/200/310 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L24/54/235/241/250/260/271 - Instead of i++ or i + 1 or i--, it is less expensive to do --i or ++i

  • L245 - Less gas is spent making variable != 0, than making variable > 0

  • L94/307/310/315/316 - A variable could be generated in memory of array.length and use that variable directly, this would generate a lower gas cost.

ethregistrar/StringUtils.sol

  • L12/14 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L14 - Instead of variable++, gas is saved by making ++variable.

registry/ReverseRegistrar.sol

  • L41/52 - Instead of using a require, you can save gas using ifs with custom errors.

  • L46/54 - When a string exceeds 32 bytes they generate a higher gas cost, try to generate messages with less than 32 characters.

wrapper/BytesUtil.sol

  • L44 - Less gas is spent making variable != 0, than making variable > 0

  • L28/45/49 - Instead of doing variable + 1 or variable - 1, you save gas by doing ++variable or --variable.

wrapper/ERC1155Fuse.sol

  • L62/87/109/176/179/197/199/202/217/252/292/322/327/354/359 - When a string exceeds 32 bytes, they generate a higher gas cost, try to generate messages with less than 32 characters.

  • L60/85/107/176/177/195/199/200/248/249/250/290 - gas could be saved if instead of using a modifier a private view function is used.

  • L86/90/92/196/205 - array.length is used several times in the balanceOfBarch() and safeBatchTransferFrom() functions and between them in a for loop, gas could be saved if a length variable was created in memory, instead of querying the length each time.

  • L92/205 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L92/205 - Gas can be saved by making the ++i unchecked.

wrapper/NameWrapper.sol

  • L150/639/657 - gas could be saved if instead of using a modifier a private view function is used.

  • L259/260/406/407/408/435/436/437/659/661 - It is not necessary to create a variable if it will only be used once within the function.

  • L746/749/752 - You could generate a bytes(label).length variable in memory and use that variable directly, this would generate a lower gas cost.

wrapper/Controllable.sol

  • L17 - When a string exceeds 32 bytes they generate a higher gas cost, try to generate messages with less than 32 characters.

  • L16 - gas could be saved if instead of using a modifier a private view function is used.

  • L17 - Instead of using a require, you can save gas using ifs with custom errors.

ethregistrar/ETHRegistrarController.sol

  • L73/74/82/83/97/107 - It is not necessary to create a variable if it will only be used once within the function.

  • L98 - Less gas is spent making variable != 0, than making variable > 0

  • L101/139/198/234/240/242/261/265 - When a string exceeds 32 bytes they generate a higher gas cost, try to generate messages with less than 32 characters.

  • L57/99/121/137/196/232/238/242/246/259 - Instead of using a require, you can save gas using ifs with custom errors.

  • L256 - array.length is used in a for loop, gas could be saved if a length variable was created in memory, instead of length being consulted each time.

  • L256 - It is not necessary to create a variable and set its default value of its type, you can save gas without setting it directly.

  • L256 - Gas can be saved by making the ++i unchecked.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jul 14, 2022
code423n4 added a commit that referenced this issue Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

1 participant