tinylib / msgp

A Go code generator for MessagePack / msgpack.org[Go]
MIT License
1.77k stars 189 forks source link

Optimize WriteExtensionRaw for stack buffers #330

Closed mhr3 closed 1 year ago

mhr3 commented 1 year ago

A small tweak to my previous PR - previously WriteExtensionRaw would cause the byte slice param to escape to heap (because of the call to io.Writer.Write in mw.Write) which meant there was still an allocation when using it with stack-allocated buffers. This fixes it by copying the data through the internal buffer.