openzeppelin-contracts icon indicating copy to clipboard operation
openzeppelin-contracts copied to clipboard

ERC20: optimized gas costs in `_spendAllowance`

Open XZSt4nce opened this issue 1 year ago • 3 comments

Fixes #5253 Used less-than operator instead of not-equal: currentAllowance < type(uint256).max instead of currentAllowance != type(uint256).max

PR Checklist

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

XZSt4nce avatar Oct 19 '24 07:10 XZSt4nce

⚠️ No Changeset found

Latest commit: 6e9aabfdd886d57cb3bd2a3035f3d0f9761601e7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

changeset-bot[bot] avatar Oct 19 '24 07:10 changeset-bot[bot]

@XZSt4nce can you provide concrete benchmarks on this change? I'm not too sure the gas difference will be even slightly significant.

cairoeth avatar Oct 19 '24 11:10 cairoeth

@cairoeth 36 gas diff image

XZSt4nce avatar Oct 20 '24 02:10 XZSt4nce

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

GitPOAP: 2024 OpenZeppelin Contracts Contributor:

GitPOAP: 2024 OpenZeppelin Contracts Contributor GitPOAP Badge

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

Learn more about GitPOAPs here.

gitpoap-bot[bot] avatar Oct 21 '24 11:10 gitpoap-bot[bot]