Description
Under the StringBuilder/List is a char array to store. If the internal buffer overflows (the default length is 16/10), it will automatically become larger. A new internal buffer will be allocated to the array copy. Although it cannot be completely avoided, it can reduce the expansion It's not bad.
E.g:
https://github.com/apache/avro/blob/87aefa28ad6cb11ab95010cdeac2223cfb701c0d/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L964
https://github.com/apache/avro/blob/87aefa28ad6cb11ab95010cdeac2223cfb701c0d/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L944
final List<?> list = (List<?>) value; final List<String> annots = new ArrayList<>(); //-----init for(Object o : list){ annots.add(o.toString()); }