Comment #8 on issue 460 by dav.co...@gmail.com: Add isDefault() to Java
Message interface as a fast means to verify whether it is a default instance
http://code.google.com/p/protobuf/issues/detail?id=460
1. getSerializedSize() is an expensive operation; yeah, it memoizes itself,
but after the first expensive run, especially on large enough objects; take
a look at its source. Also, in most cases, you don't want to call it early,
if at all in cases when
serialization is not needed, for example you've got a Message and want to
process it, but don't plan put it back on wire, why will you want the
expense then?
2. getSerializedSize() is an implementation detail (used inside
serialization, so regular users don't know much about, and usually
shouldn't).
3. when LazyField is used, I am not sure whether de-serializing its
ByteString will always give the same getSerializedSize(); at least it will
force the ByteString to be converted to the regular format, and then will
calculate the serialized size.
4. isDefault(), on the other hand, deals only with the empty object, and
fails otherwise; it's abijg difference!
5. Now give yourself the following exercise: you've got a Message, you
don't know its real class, how would you know whether it's empty/default or
not? And it is important for you to know for a number of reasons, including
whether do any further processing,
for fast performance using any merge and its derivatives, etc...
Cheers,
David
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.