aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2015-06-17 14:59:10 +0100
committerJon Skeet <skeet@pobox.com>2015-06-17 14:59:10 +0100
commit828b7e61d0443832d99002fbda12a359e5f9f221 (patch)
tree1f271cdb345b968dba08947b9319ba7d738f3476 /src/google/protobuf/compiler/csharp/csharp_enum_field.cc
parentfb1547b3884ace3be6acf9e947686d627ff90179 (diff)
downloadprotobuf-828b7e61d0443832d99002fbda12a359e5f9f221.tar.gz
protobuf-828b7e61d0443832d99002fbda12a359e5f9f221.tar.bz2
protobuf-828b7e61d0443832d99002fbda12a359e5f9f221.zip
Use the fact that we know the tag size and bytes at codegen time to optimize.
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_enum_field.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_enum_field.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
index 19fd50cf..af34f50c 100644
--- a/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
@@ -61,7 +61,8 @@ void EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
void EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
printer->Print(variables_,
"if ($has_property_check$) {\n"
- " output.WriteEnum($number$, (int) $property_name$);\n"
+ " output.WriteRawTag($tag_bytes$);\n"
+ " output.WriteEnum((int) $property_name$);\n"
"}\n");
}
@@ -69,7 +70,7 @@ void EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
printer->Print(
variables_,
"if ($has_property_check$) {\n"
- " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n"
+ " size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\n"
"}\n");
}
@@ -93,7 +94,8 @@ void EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
printer->Print(
variables_,
"if ($has_property_check$) {\n"
- " output.WriteEnum($number$, (int) $property_name$);\n"
+ " output.WriteRawTag($tag_bytes$);\n"
+ " output.WriteEnum((int) $property_name$);\n"
"}\n");
}
@@ -101,7 +103,7 @@ void EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {
printer->Print(
variables_,
"if ($has_property_check$) {\n"
- " size += pb::CodedOutputStream.ComputeEnumSize($number$, (int) $property_name$);\n"
+ " size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\n"
"}\n");
}