From 828b7e61d0443832d99002fbda12a359e5f9f221 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 17 Jun 2015 14:59:10 +0100 Subject: Use the fact that we know the tag size and bytes at codegen time to optimize. --- src/google/protobuf/compiler/csharp/csharp_message_field.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/google/protobuf/compiler/csharp/csharp_message_field.cc') diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 804a5ae2..bd67aa0f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -92,11 +92,11 @@ void MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) { } void MessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) { - // TODO(jonskeet): Why are we using array access instead of a literal here? printer->Print( variables_, "if ($has_property_check$) {\n" - " output.WriteMessage($number$, $property_name$);\n" + " output.WriteRawTag($tag_bytes$);\n" + " output.WriteMessage($property_name$);\n" "}\n"); } @@ -104,7 +104,7 @@ void MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) { printer->Print( variables_, "if ($has_property_check$) {\n" - " size += pb::CodedOutputStream.ComputeMessageSize($number$, $property_name$);\n" + " size += $tag_size$ + pb::CodedOutputStream.ComputeMessageSize($property_name$);\n" "}\n"); } -- cgit v1.2.3