Re: [protobuf] Re: Builders containing builders

2009-12-16 Thread Kenton Varda
toBuilder() makes only a shallow copy of the object. It does not copy the contents of individual Strings, ByteStrings, sub-messages, etc.; it just reuses the existing values. This means that it's generally reasonably cheap, although obviously not quite as cheap as if the builders for sub-objects

[protobuf] Re: Builders containing builders

2009-12-16 Thread Mark
Yes, this seems nice: Foo.Builder builder; builder.setBar(builder.getBar().toBuilder().setA(...).build()); But I guess I'm a little worried about its hidden cost if I use it a lot. If message Bar was very large, then would converting it to a builder, setting one value, and converting it back to a