msgpack / msgpack-ruby

MessagePack implementation for Ruby / msgpack.org[Ruby]
http://msgpack.org/
Apache License 2.0
764 stars 117 forks source link

Refactor buffer views #318

Closed casperisfine closed 1 year ago

casperisfine commented 1 year ago

Two commits for two changes here.

First we no longer set a mark function for msgpack:buffer_view objects, instead we mark the msgpack_buffer_t struct from the owner (packer or unpacker) mark function. This IMO is much cleaner, and allow us to no longer create the Buffer instance eagerly for GC purposes. Given that accessing the buffer is a very rare use case, it is a bit wasteful.

The second change is simply to remove #dup and #clone on all the classes that never intended to have them defined. Closing buffer, packer or unpacker would copy the content of the struct, but that's a shallow copy so it might lead to leaks or use after frees etc.