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

Some codes need optimization #23

Closed
gzliudan opened this issue Aug 21, 2022 · 1 comment
Closed

Some codes need optimization #23

gzliudan opened this issue Aug 21, 2022 · 1 comment

Comments

@gzliudan
Copy link

I found this library from a third contract. And maybe some codes can be optimized to save gas. For example: xc > 0x1 is better than xc >= 0x2. In Solidity, there is no single op-code for ≤ or ≥ expressions. Solidity compiler executes the LT/GT (less than/greater than) op-code and afterwards it executes an ISZERO op-code to check if the result of the previous comparison (LT/ GT) is zero and validate it or not. So the use of < and > are cheaper than ≤ and ≥.

@3sGgpQ8H
Copy link
Contributor

3sGgpQ8H commented Oct 9, 2022

This should probably be reported to the Solidity team, as compiler should know how to use the available opcodes in the most efficient way.

@3sGgpQ8H 3sGgpQ8H closed this as completed Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants