Closed jsallay closed 2 years ago
I dug in and did some investigation. Fixing this is going to require several changes to the pmt_base class. In particular in the serialize function, we take in a FlatBufferBuilder and process that. We cannot recreate a builder from a serialized buffer (as far as I can tell) in the deserialize function. This means that right now, we must create a new builder and then copy in the data.
I believe that we can store the data in serialized form at all times and just work with the buffers. I think this will have the side effect of making the pmt_base class much simpler as well.
Pmt vectors (and other pmts for that matter) are initialized by creating a flatbuffer and then copying the contents or another array or pmt in. This frequently results in an extra copy of data, which should be avoidable. (For example, we deserialize so that we can figure out what type of data we have (doing a copy) and then we copy the data into a new pmt vector (doing another copy). We should investigate move constructors to make it more efficient.