aboutsummaryrefslogtreecommitdiffstats
path: root/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_primitive_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_primitive_field.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
index f5b25b6..1cf9066 100644
--- a/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
@@ -391,8 +391,20 @@ GenerateParsingCode(io::Printer* printer) const {
} else {
printer->Print(variables_,
"int arrayLength = com.google.protobuf.nano.WireFormatNano.getRepeatedFieldArrayLength(input, $tag$);\n"
- "int i = this.$name$.length;\n"
- "this.$name$ = java.util.Arrays.copyOf(this.$name$, this.$name$.length + arrayLength);\n"
+ "int i = this.$name$.length;\n");
+
+ if (GetJavaType(descriptor_) == JAVATYPE_BYTES) {
+ printer->Print(variables_,
+ "byte[][] newArray = new byte[i + arrayLength][];\n"
+ "System.arraycopy(this.$name$, 0, newArray, 0, i);\n"
+ "this.$name$ = newArray;\n");
+ } else {
+ printer->Print(variables_,
+ "$type$[] newArray = new $type$[i + arrayLength];\n"
+ "System.arraycopy(this.$name$, 0, newArray, 0, i);\n"
+ "this.$name$ = newArray;\n");
+ }
+ printer->Print(variables_,
"for (; i < this.$name$.length - 1; i++) {\n"
" this.$name$[i] = input.read$capitalized_type$();\n"
" input.readTag();\n"