avoid Rlp::Util.binary_add's segmented IO operations
instead, make all methods have an overload write to an IO, and the other overload which returns Bytes just creates an IO::Memory and calls the other overload.
ref https://www.reddit.com/r/crystal_programming/comments/ev2xig/wrote_a_native_library_implementing_rlp_recursive/
def self.encode(anything)
io = IO::Memory.new
encode(anything, io)
io.to_slice # maybe add dup here
end
def self.encode(b : Bytes, io)
# encode b into io
end
# and so on for other types
ref https://github.com/crystal-lang/crystal/blob/47bdbaa4d1638c76137bfa12de86eac454a15908/src/object.cr#L94-L105
avoid
Rlp::Util.binary_add's segmentedIOoperationsinstead, make all methods have an overload write to an
IO, and the other overload which returnsBytesjust creates anIO::Memoryand calls the other overload.ref https://www.reddit.com/r/crystal_programming/comments/ev2xig/wrote_a_native_library_implementing_rlp_recursive/
ref https://github.com/crystal-lang/crystal/blob/47bdbaa4d1638c76137bfa12de86eac454a15908/src/object.cr#L94-L105