On Tue, Mar 9, 2010 at 3:41 AM, Evan Jones ev...@mit.edu wrote:
On Mar 9, 2010, at 3:21 , Paul Rudd wrote:
Which actually brings up a feature request -
MessageLite.Builder.mergeDelimitedFrom(InputStream) is too inefficient
for small streamed messages, since it creates a new CodedInputStream
(and 4KB buffer to go with it) every time. The addition of a
mergeDelimitedFrom(CodedInputStream) would be welcomed.
You can do this yourself. I think the following would work:
int length = inputStream.readRawVarint32();
int oldLimit = inputStream.pushLimit(length);
builder.mergeFrom(inputStream);
inputStream.popLimit(oldLimit);
Yep, that works.
In fact, you can even do the above in one line:
codedInput.readMessage(builder, ExtensionRegistryLite.getEmptyRegistry());
It turns out that since readMessage() assumes the tag was already read, it
parses the exact same format that mergeDelimitedFrom() does.
--
You received this message because you are subscribed to the Google Groups
Protocol Buffers group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.