Hi, What's the best practices on updating generated Message objects?
I use google-protobuf to generate Java classes according to proto file, since these classes are immutable so I need to use its Builder to copy/close the object and then update it. It is okay for a few update on the message object, however, it will not perform well if I do multiple update on its field in different methods several times, because it asked me to copy/clone the object everytime. I know I can pass Builder object instead of message object, but the builder object also asked me to copy/clone its reference. E.g. // I want to update MyObject's instance myobject MyObject.Builder myBuilder = MyObject .newBuilder( myobject); //copy & clone myBuilder.setPrice(Price.newBuilder(tmdObject.getPrice()).setValue(123));// 1st copy & clone myBuilder.setPrice(Price.newBuilder(tmdObject.getPrice()).setValue(456));// 2nd copy & clone myobject = myBuilder.build(); Can we reduce the copy&clone during update an object? Could you please let me know what is the best way to update an existing protobuf object? David -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. 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.
