Optimize Strings.equal (#4262)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
5
.changeset/eighty-crabs-listen.md
Normal file
5
.changeset/eighty-crabs-listen.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'openzeppelin-solidity': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Optimize `Strings.equal`
|
||||||
@ -80,6 +80,6 @@ library Strings {
|
|||||||
* @dev Returns true if the two strings are equal.
|
* @dev Returns true if the two strings are equal.
|
||||||
*/
|
*/
|
||||||
function equal(string memory a, string memory b) internal pure returns (bool) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user