We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ffceb3c commit 253bfa6Copy full SHA for 253bfa6
.changeset/eighty-crabs-listen.md
@@ -0,0 +1,5 @@
1
+---
2
+'openzeppelin-solidity': patch
3
4
+
5
+Optimize `Strings.equal`
contracts/utils/Strings.sol
@@ -80,6 +80,6 @@ library Strings {
80
* @dev Returns true if the two strings are equal.
81
*/
82
function equal(string memory a, string memory b) internal pure returns (bool) {
83
- return keccak256(bytes(a)) == keccak256(bytes(b));
+ return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
84
}
85
0 commit comments