Does anyone have any insight on Evan's "related question" below? On Thu, Jun 17, 2010 at 5:05 PM, Evan Jones <[email protected]> wrote: > Related question: If I am writing length-prefixed values, what is the "best" > way to do this? I think there are 3 approaches: > > 1. out.WriteVarint32(msg.ByteSize()); msg.SerializeToCodedStream(&out); > > This approach will choose between the "ToArray" and "regular" versions of > the Serialize method, as appropriate. However, it computes the ByteSize > twice. > > 2. out.WriteVarint32(msg.ByteSize()); msg.SerializeWithCachedSizes(&out); > > This computes the ByteSize once, but never uses the "fast path" ToArray > method. > > 3. Some custom code that calls ByteSize once, then chooses between the > "fast" and "slow" methods, as appropriate. Is there actually any significant > difference in performance between SerializeWithCachedSizes and > SerializeWithCachedSizesToArray, so it would be worth me actually doing > this?
-Andy -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.
