Use bytes8 index access (#19)
Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
This commit is contained in:
parent
8f2c64485e
commit
a2e1e5aef0
|
@ -141,15 +141,16 @@ contract DepositContract is IDepositContract, ERC165 {
|
|||
}
|
||||
|
||||
function to_little_endian_64(uint64 value) internal pure returns (bytes memory ret) {
|
||||
// Unrolled the loop here.
|
||||
ret = new bytes(8);
|
||||
ret[0] = bytes1(uint8(value));
|
||||
ret[1] = bytes1(uint8(value >> 8));
|
||||
ret[2] = bytes1(uint8(value >> 16));
|
||||
ret[3] = bytes1(uint8(value >> 24));
|
||||
ret[4] = bytes1(uint8(value >> 32));
|
||||
ret[5] = bytes1(uint8(value >> 40));
|
||||
ret[6] = bytes1(uint8(value >> 48));
|
||||
ret[7] = bytes1(uint8(value >> 56));
|
||||
bytes8 bytesValue = bytes8(value);
|
||||
// Byteswapping during copying to bytes.
|
||||
ret[0] = bytesValue[7];
|
||||
ret[1] = bytesValue[6];
|
||||
ret[2] = bytesValue[5];
|
||||
ret[3] = bytesValue[4];
|
||||
ret[4] = bytesValue[3];
|
||||
ret[5] = bytesValue[2];
|
||||
ret[6] = bytesValue[1];
|
||||
ret[7] = bytesValue[0];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue