On Sat, Dec 6, 2008 at 1:03 AM, Alek Storm <[EMAIL PROTECTED]> wrote:

> But it does give us a lot of cool functionality, like adding the same
> message to two parents, and (yes!) slicing support.  I thought this was
> common practice in C++, but it's been quite a while since I've coded it.
>

Nope, in the C++ world we have to worry excessively about ownership, and we
generally make defensive copies rather than trying to allow an object to be
referenced from two places.


> Is it really that useful to have ByteSize() cached for repeated fields?  If
> it's not, we get everything I mentioned above for free.  I'm genuinely not
> sure - it only comes up when serializing the message in wire_format.py.
> What do you think?
>

Yes, it's just as necessary as it is with optional fields.  The main problem
is that the size of a message must be written before the message contents
itself.  If, while serializing, you call ByteSize() to get this size every
time you write a message, then you'll end up computing the size of
deeply-nested messages many times (once for each outer message within which
they're nested).  Caching avoids that problem.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to