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

feat: use assembly in mostSignificantBit #133

Closed
wants to merge 1 commit into from
Closed

Conversation

t4sk
Copy link
Contributor

@t4sk t4sk commented Nov 28, 2022

Rewrite mostSignificantBit using assembly. Code is copied from Uniswap V3 library.

https://github.com/Uniswap/v3-core/blob/05c10bf6d547d6121622ac51c457f93775e1df09/contracts/libraries/TickMath.sol#L66-L107

Quick test on Remix IDE shows that code written in assembly can save up to about 1500 gas

function or assembly? input gas
function max uint 24067 gas
function 0 21948 gas
assembly max uint 22488 gas
assembly 0 22104 gas

@PaulRBerg
Copy link
Owner

PaulRBerg commented Nov 28, 2022

Hello! This is great, thanks very much for opening a PR.

I apologize for the hassle, but I am on the cusp of releasing PRBMath V3 from the staging branch.

Could I kindly ask you to re-apply your changes onto the tip of the staging branch, and git push with force to your branch?

I would also be happy to do the above myself, but then you wouldn't show up as a contributor anymore.

@PaulRBerg PaulRBerg changed the base branch from main to staging November 28, 2022 09:21
@t4sk
Copy link
Contributor Author

t4sk commented Nov 28, 2022

sure

@PaulRBerg
Copy link
Owner

Don't worry, I managed to re-implement this myself. I will close this PR in favor of #135.

I made sure that you remain a git author by modifying the git commit body and referencing you there.

@PaulRBerg PaulRBerg closed this Nov 28, 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

Successfully merging this pull request may close these issues.

2 participants