diff options
author | csharptest <roger@csharptest.net> | 2011-06-03 11:57:47 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-03 11:57:47 -0500 |
commit | 90922db77aef8bd7f21e7a87a75d86885da8dbbc (patch) | |
tree | b86202690d68a01341c2232477657a4da27f7375 /src/ProtoGen/RepeatedEnumFieldGenerator.cs | |
parent | 8a2d0f48d70bd760bf26218f7107c86ca9f91cce (diff) | |
download | protobuf-90922db77aef8bd7f21e7a87a75d86885da8dbbc.tar.gz protobuf-90922db77aef8bd7f21e7a87a75d86885da8dbbc.tar.bz2 protobuf-90922db77aef8bd7f21e7a87a75d86885da8dbbc.zip |
Added the field name to all CodedOutputStream.Write??? calls
Refactored 'speed' generated write of arrays to call Write???Array. This may
have impacted speed write speeds for arrays of non-reference types due to the
use of non-generic IEnumerable and the subsequent boxing of value types. This
could be addressed later if desired.
Diffstat (limited to 'src/ProtoGen/RepeatedEnumFieldGenerator.cs')
-rw-r--r-- | src/ProtoGen/RepeatedEnumFieldGenerator.cs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/ProtoGen/RepeatedEnumFieldGenerator.cs b/src/ProtoGen/RepeatedEnumFieldGenerator.cs index e98bc929..e3fdd657 100644 --- a/src/ProtoGen/RepeatedEnumFieldGenerator.cs +++ b/src/ProtoGen/RepeatedEnumFieldGenerator.cs @@ -149,19 +149,23 @@ namespace Google.ProtocolBuffers.ProtoGen writer.WriteLine("if ({0}_.Count > 0) {{", Name);
writer.Indent();
if (Descriptor.IsPacked)
- {
- writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
- writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
- writer.WriteLine("foreach (int element in {0}_) {{", Name);
- writer.WriteLine(" output.WriteEnumNoTag(element);");
- writer.WriteLine("}");
- }
+ writer.WriteLine("output.WritePackedArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}MemoizedSerializedSize, {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
else
- {
- writer.WriteLine("foreach (int element in {0}_) {{", Name);
- writer.WriteLine(" output.WriteEnum({0}, element);", Number);
- writer.WriteLine("}");
- }
+ writer.WriteLine("output.WriteArray(pbd::FieldType.{3}, {0}, \"{2}\", {1}_);", Number, Name, Descriptor.Name, Descriptor.FieldType);
+ //if (Descriptor.IsPacked)
+ //{
+ // writer.WriteLine("output.WriteRawVarint32({0});", WireFormat.MakeTag(Descriptor));
+ // writer.WriteLine("output.WriteRawVarint32((uint) {0}MemoizedSerializedSize);", Name);
+ // writer.WriteLine("foreach (int element in {0}_) {{", Name);
+ // writer.WriteLine(" output.WriteEnumNoTag(element);");
+ // writer.WriteLine("}");
+ //}
+ //else
+ //{
+ // writer.WriteLine("foreach (int element in {0}_) {{", Name);
+ // writer.WriteLine(" output.WriteEnum({0}, element);", Number);
+ // writer.WriteLine("}");
+ //}
writer.Outdent();
writer.WriteLine("}");
}
|