Skip to content

reduce pressure on garbage collector #6

Description

@q9f

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions