Closed GoogleCodeExporter closed 9 years ago
This is use-case dependent.
Using intern isn't always a good thing.
See
http://stackoverflow.com/questions/2431540/garbage-collection-behaviour-for-stri
ng-intern
Original comment by david.yu...@gmail.com
on 8 Feb 2011 at 11:17
Ah, I see. Okay, maybe there is an option to implement an "intern()" in the
generated "Builder mergeFrom()"-method that I could set in the the .proto-File
for a specific attribute like I can do that with "deprecated"?
Original comment by stefan.o...@gmail.com
on 8 Feb 2011 at 4:24
intern() only works well if you have many different strings with the same
values. In that case, you should probably consider reworking your protocol.
Perhaps you should be using an enum instead? Or maybe you should have a
separate string list that only stores one copy of each value, and then in other
places you should store indexes into that list?
I don't think we want to add an option for this because the use case is too
obscure. Options have a cost in terms of system complexity, maintainability,
and learnability.
Original comment by kenton@google.com
on 8 Feb 2011 at 9:33
Original issue reported on code.google.com by
stefan.o...@gmail.com
on 8 Feb 2011 at 11:06