nanopack-buffer / cxx-nanopack

NanoPack is a simple binary serialization format
MIT License
3 stars 0 forks source link

Investigate using shared buffer when serializing messages with message fields #1

Open kennethnym opened 8 months ago

kennethnym commented 8 months ago

Consider the following two messages:

A:
  typeid: 1
  msg: B:0

B:
  typeid: 2
  str: string:0

At the moment, when serializing A.b, a separate buffer is allocated to store the bytes of B, and then it is copied to the byte buffer of A. It should be possible to pre-allocate a bigger buffer when serializing A that is passed to the serialization func of B, to avoid unnecessary alloc and copying.