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

⚡️ Optimise mul_div Method #153

Merged
merged 1 commit into from
Aug 4, 2023
Merged

⚡️ Optimise mul_div Method #153

merged 1 commit into from
Aug 4, 2023

Conversation

pcaversaccio
Copy link
Owner

@pcaversaccio pcaversaccio commented Aug 4, 2023

We simplify the twos calculation in mul_div in a similar way as proposed here. This will save one operation.

image

Explanation: -x in two's complement (where x is uint256) is defined as ~x + 1 which is max_value(uint256) - x + 1. Thus, -x -> 0 + max_value(uint256) - x + 1 -> unsafe_sub(0, x) as long as x>=1 holds.

Furthermore, we bump eslint-config-prettier, ethers, and prettier to the corresponding latest versions. Eventually, the submodule openzeppelin-contracts is bumped to the latest available commit.

🐶 Cute Animal Picture

image

Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
@pcaversaccio pcaversaccio added documentation 📖 Improvements or additions to documentation dependencies 🔁 Pull requests that update a dependency file optimisation ⚡️ Code optimisations (e.g. gas improvements) labels Aug 4, 2023
@pcaversaccio pcaversaccio added this to the 0.0.3 milestone Aug 4, 2023
@pcaversaccio pcaversaccio self-assigned this Aug 4, 2023
@pcaversaccio pcaversaccio merged commit 1db346f into main Aug 4, 2023
10 checks passed
@pcaversaccio pcaversaccio deleted the optimise-muldiv branch August 4, 2023 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies 🔁 Pull requests that update a dependency file documentation 📖 Improvements or additions to documentation optimisation ⚡️ Code optimisations (e.g. gas improvements)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant