The advantage of writing the length is that a parser can skip the entire
sub-message easily without having to parse its contents.  Otherwise, we
would probably use the "group" encoding for sub-messages, where a special
end tag marks the end of the message.

On Tue, Jun 23, 2009 at 9:06 AM, etorri <> wrote:

> Hello,
> The "length delimited" encoding basically tells that the following N
> bytes belong to this field. Wouldn't it be easier to instead use the
> number of elements that belong to the embedded message (repeated
> element).
> Now (as far as I have understood) the message needs to be built from
> fragments and then collected together as the lengths are not known
> beforehand and it would be expensive to calculate the byte-length of
> the embedded message.
> Instead, it would be relatively inexpensive to calculate just the
> number of following elements that make the embedded message before
> starting to encode it.
> This would enable streaming of PB or encoding and sending the elements
> right as they are encoded.
> Sorry if I misunderstood something. I have just started looking at BP.
> >

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to