solmate
solmate copied to clipboard
Optimized Bytes32AddressLibs by using assembly and bit operations
Description
Optimized Bytes32AddressLibs by using assembly and bit operations
used assembly and bit operations to save 31+ in runtime gas Previously
library Bytes32AddressLib {
function fillLast12Bytes(address addressValue) internal pure returns (bytes32) {
return bytes32(bytes20(addressValue));
}
}
Changes
function fillLast12Byte(address addressValue)
external
pure
returns (bytes32 _addr)
{
assembly{
_addr := shl(96, addressValue)
}
}