Skip to content

Commit 3400f3d

Browse files
committed
feat: slight optimization to hashStruct
1 parent 2166533 commit 3400f3d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/modules/ReplaySafeWrapper.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ abstract contract ReplaySafeWrapper is ModuleEIP712 {
2626
});
2727
}
2828

29-
function _hashStruct(bytes32 hash) internal view virtual returns (bytes32) {
30-
return keccak256(abi.encode(_REPLAY_SAFE_HASH_TYPEHASH, hash));
29+
function _hashStruct(bytes32 hash) internal pure virtual returns (bytes32) {
30+
bytes32 res;
31+
assembly ("memory-safe") {
32+
mstore(0x00, _REPLAY_SAFE_HASH_TYPEHASH)
33+
mstore(0x20, hash)
34+
res := keccak256(0x00, 0x40)
35+
}
36+
return res;
3137
}
3238
}

0 commit comments

Comments
 (0)