Skip to content

Commit 554f2a0

Browse files
committed
Optimize Strings equal
1 parent 96b9559 commit 554f2a0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/eighty-crabs-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
Optimize Strings equal

contracts/utils/Strings.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ library Strings {
8080
* @dev Returns true if the two strings are equal.
8181
*/
8282
function equal(string memory a, string memory b) internal pure returns (bool) {
83-
return keccak256(bytes(a)) == keccak256(bytes(b));
83+
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
8484
}
8585
}

0 commit comments

Comments
 (0)