solidity-bytes-utils
solidity-bytes-utils copied to clipboard
Understanding concatStorage function
@GNSPS First of all, thanks for writing a great library!
I'm having a hard time understanding the following line:
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
What happens when slength and newlength are lower than 31 but slength + newlength exceeds the 31 length limit?
_preBytes is now a long array and we should use a different encoding.
But as far as I understand, current implementation still regards it as a short array.
Do I miss anything?