Skip to content

Conversation

@malik672
Copy link

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)
        }
    }
malik672 and others added 3 commits October 14, 2023 21:02
optimize fromLast20Bytes
optimized fillLast12Bytes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant