aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/csharp/csharp_message.cc
diff options
context:
space:
mode:
authorGravatar Jon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
commit96ddf01aed1a49d73a7fda50e28c431ffc977e5a (patch)
tree4f603245ff514486481f126ca8d81deeff572534 /src/google/protobuf/compiler/csharp/csharp_message.cc
parent39aaf21d5194fdc07c296847def8e7795279e041 (diff)
Coded*Stream streamlining.
Remove ICodedInputStream and ICodedOutputStream, and rewrite CodedInputStream and CodedOutputStream to be specific to the binary format. If we want to support text-based formats, that can be a whole different serialization mechanism.
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_message.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_message.cc17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc
index b5929bcd..aca68fb7 100644
--- a/src/google/protobuf/compiler/csharp/csharp_message.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -350,9 +350,8 @@ void MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {
void MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) {
printer->Print(
- "public void WriteTo(pb::ICodedOutputStream output) {\n");
+ "public void WriteTo(pb::CodedOutputStream output) {\n");
printer->Indent();
- printer->Print("string[] fieldNames = _fieldNames;\n");
// Serialize all the fields
for (int i = 0; i < fields_by_number().size(); i++) {
@@ -423,21 +422,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
}
printer->Outdent();
printer->Print("}\n\n");
- printer->Print("public void MergeFrom(pb::ICodedInputStream input) {\n");
+ printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n");
printer->Indent();
printer->Print(
"uint tag;\n"
- "string fieldName;\n"
- "while (input.ReadTag(out tag, out fieldName)) {\n");
+ "while (input.ReadTag(out tag)) {\n"
+ " switch(tag) {\n");
printer->Indent();
- printer->Print(
- "if (tag == 0 && fieldName != null) {\n"
- " int fieldOrdinal = global::System.Array.BinarySearch(_fieldNames, fieldName, global::System.StringComparer.Ordinal);\n"
- " if (fieldOrdinal >= 0) {\n"
- " tag = _fieldTags[fieldOrdinal];\n"
- " }\n"
- "}\n"
- "switch(tag) {\n");
printer->Indent();
printer->Print(
"case 0:\n" // 0 signals EOF / limit reached