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

Remove duplicated SLOAD in Arrays.findUpperBound #4442

Merged
merged 3 commits into from Jul 12, 2023

Conversation

molly-ting
Copy link
Contributor

Reading a variable in storage costs more gas than reading a variable in memory.
Replacing load of array.length with load of local variable high can save gas.

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@changeset-bot
Copy link

changeset-bot bot commented Jul 10, 2023

🦋 Changeset detected

Latest commit: 347e56c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its actually not a mload, because high will be in the stack and not in memory.

@Amxx Amxx changed the title change SLOAD to MLOAD to save gas Remove duplicated SLOAD in Array.findUpperBound Jul 10, 2023
@Amxx Amxx changed the title Remove duplicated SLOAD in Array.findUpperBound Remove duplicated SLOAD in Arrays.findUpperBound Jul 10, 2023
Amxx
Amxx previously approved these changes Jul 10, 2023
@frangio frangio merged commit 0abf18f into OpenZeppelin:master Jul 12, 2023
12 of 13 checks passed
@gitpoap-bot
Copy link

gitpoap-bot bot commented Jul 12, 2023

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 OpenZeppelin Contracts Contributor:

GitPOAP: 2023 OpenZeppelin Contracts Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

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.

None yet

3 participants