Skip to content

Commit

Permalink
Optimize Strings equal
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSandwich committed May 31, 2023
1 parent 96b9559 commit 554f2a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-crabs-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

Optimize Strings equal
2 changes: 1 addition & 1 deletion contracts/utils/Strings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ library Strings {
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}

0 comments on commit 554f2a0

Please sign in to comment.