diff options
author | Jon Skeet <skeet@pobox.com> | 2015-06-12 11:52:14 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-06-12 11:52:14 +0100 |
commit | 5a33827eec75b980fb152c531e4c6b75ce5af015 (patch) | |
tree | df7cb0b09126f11ab1ca905558015d6469107d5b /src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc | |
parent | 5685e987112077b2df9fc59acfbfa30f1e3ea38b (diff) |
Move Count checks into the serialization code
I wouldn't expect this to affect anything, but it appears to.
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc index d7e4d80f..4b570d3b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc @@ -83,7 +83,9 @@ void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* print // The Write* call should make that cheap though - no need to generate it every time. printer->Print( variables_, - "output.WriteMessageArray($number$, $name$_);\n"); + "if ($name$_.Count > 0) {\n" + " output.WriteMessageArray($number$, $name$_);\n" + "}\n"); } void RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { |