correct use CapnProto #1974
-
Hi all. i want to use capnproto as serialization library. Am I using the library correctly? or it can be done more optimally and correctly.
regards, max |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This looks like it's making at least three copies of the message content: Similarly on the read side you are reading into a |
Beta Was this translation helpful? Give feedback.
This looks like it's making at least three copies of the message content:
messageToFlatArray
makes one, constructing a vector is a second, andappendBytes()
is a third. This could be more efficient if you implement a subclass ofkj::OutputStream
which writes directly to yourBlob
, then usecapnp::writeMessage(message, stream)
.Similarly on the read side you are reading into a
std::vector
first, and then copying that into akj::Array
. The best would be if you …