aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-06-09 19:47:56 -0500
committerrogerk <devnull@localhost>2011-06-09 19:47:56 -0500
commitced18e10ae9ca41f338c9e788642d705dd17f9d4 (patch)
tree334ca02758aca596df2b71fb4ada50db71aa4913 /src/ProtocolBuffers
parent367e02261c6bee9bce37cb6942bd6cbf743fb67c (diff)
downloadprotobuf-ced18e10ae9ca41f338c9e788642d705dd17f9d4.tar.gz
protobuf-ced18e10ae9ca41f338c9e788642d705dd17f9d4.tar.bz2
protobuf-ced18e10ae9ca41f338c9e788642d705dd17f9d4.zip
Several performance tweaks
- Removed default value assingment when default is equal to default(T) - Added Benchmarks for most types and repeated/packed arrays - Left PopsicleList's list fields uninitialized util needed - Changed CodedInputStream's repated/packed reader - Changed Enum writers to simply cast to int - Changed the WriteEnum to use object rawValue that provides .ToString() if needed - Should be fully on par with original library for performance, gaining 2x-3x in some cases
Diffstat (limited to 'src/ProtocolBuffers')
-rw-r--r--src/ProtocolBuffers/CodedInputStream.cs255
-rw-r--r--src/ProtocolBuffers/CodedOutputStream.cs29
-rw-r--r--src/ProtocolBuffers/Collections/IPopsicleList.cs8
-rw-r--r--src/ProtocolBuffers/Collections/PopsicleList.cs50
-rw-r--r--src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs14
-rw-r--r--src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs34
-rw-r--r--src/ProtocolBuffers/ICodedInputStream.cs7
-rw-r--r--src/ProtocolBuffers/ICodedOutputStream.cs2
8 files changed, 336 insertions, 63 deletions
diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs
index 1fea7346..aad47f96 100644
--- a/src/ProtocolBuffers/CodedInputStream.cs
+++ b/src/ProtocolBuffers/CodedInputStream.cs
@@ -516,8 +516,13 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Returns true if the next tag is also part of the same unpacked array
/// </summary>
- private bool ContinueArray(uint currentTag)
+ private bool ContinueArray(uint currentTag, bool packed)
{
+ if (packed)
+ {
+ return !ReachedLimit;
+ }
+
string ignore;
uint next;
if (PeekNextTag(out next, out ignore))
@@ -532,7 +537,7 @@ namespace Google.ProtocolBuffers
}
[CLSCompliant(false)]
- public void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list)
+ public void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list)
{
WireFormat.WireType normal = WireFormat.GetWireType(fieldType);
WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
@@ -546,7 +551,7 @@ namespace Google.ProtocolBuffers
{
Object value = null;
if(ReadPrimitiveField(fieldType, ref value))
- list.Add((T)value);
+ list.Add(value);
}
PopLimit(limit);
}
@@ -556,9 +561,241 @@ namespace Google.ProtocolBuffers
do
{
if (ReadPrimitiveField(fieldType, ref value))
- list.Add((T)value);
+ list.Add(value);
}
- while (ContinueArray(fieldTag));
+ while (ContinueArray(fieldTag, false));
+ }
+ }
+
+ [CLSCompliant(false)]
+ public void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list)
+ {
+ WireFormat.WireType normal = WireFormat.GetWireType(fieldType);
+ WireFormat.WireType wformat = WireFormat.GetTagWireType(fieldTag);
+
+ // 2.3 allows packed form even if the field is not declared packed.
+ if (normal != wformat && wformat == WireFormat.WireType.LengthDelimited)
+ {
+ int length = (int)(ReadRawVarint32() & int.MaxValue);
+ int limit = PushLimit(length);
+ //while (!ReachedLimit)
+ //{
+ // Object value = null;
+ // if (ReadPrimitiveField(fieldType, ref value))
+ // list.Add((T)value);
+ //}
+ if (!ReachedLimit)
+ ReadPrimitiveArrayItems(fieldType, fieldTag, list, true);
+
+ PopLimit(limit);
+ }
+ else
+ {
+ ReadPrimitiveArrayItems(fieldType, fieldTag, list, false);
+ //Object value = null;
+ //do
+ //{
+ // if (ReadPrimitiveField(fieldType, ref value))
+ // list.Add((T)value);
+ //}
+ //while (ContinueArray(fieldTag, false));
+ }
+ }
+
+ void ReadPrimitiveArrayItems<T>(FieldType fieldType, uint fieldTag, ICollection<T> list, bool packed)
+ {
+ switch (fieldType)
+ {
+ case FieldType.Double:
+ {
+ ICollection<double> output = (ICollection<double>)list;
+ double tmp = 0;
+ do
+ {
+ ReadDouble(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Float:
+ {
+ ICollection<float> output = (ICollection<float>)list;
+ float tmp = 0;
+ do
+ {
+ ReadFloat(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Int64:
+ {
+ ICollection<long> output = (ICollection<long>)list;
+ long tmp = 0;
+ do
+ {
+ ReadInt64(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.UInt64:
+ {
+ ICollection<ulong> output = (ICollection<ulong>)list;
+ ulong tmp = 0;
+ do
+ {
+ ReadUInt64(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Int32:
+ {
+ ICollection<int> output = (ICollection<int>)list;
+ int tmp = 0;
+ do
+ {
+ ReadInt32(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Fixed64:
+ {
+ ICollection<ulong> output = (ICollection<ulong>)list;
+ ulong tmp = 0;
+ do
+ {
+ ReadFixed64(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Fixed32:
+ {
+ ICollection<uint> output = (ICollection<uint>)list;
+ uint tmp = 0;
+ do
+ {
+ ReadFixed32(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Bool:
+ {
+ ICollection<bool> output = (ICollection<bool>)list;
+ bool tmp = false;
+ do
+ {
+ ReadBool(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.String:
+ {
+ ICollection<string> output = (ICollection<string>)list;
+ string tmp = null;
+ do
+ {
+ ReadString(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Bytes:
+ {
+ ICollection<ByteString> output = (ICollection<ByteString>)list;
+ ByteString tmp = null;
+ do
+ {
+ ReadBytes(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.UInt32:
+ {
+ ICollection<uint> output = (ICollection<uint>)list;
+ uint tmp = 0;
+ do
+ {
+ ReadUInt32(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.SFixed32:
+ {
+ ICollection<int> output = (ICollection<int>)list;
+ int tmp = 0;
+ do
+ {
+ ReadSFixed32(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.SFixed64:
+ {
+ ICollection<long> output = (ICollection<long>)list;
+ long tmp = 0;
+ do
+ {
+ ReadSFixed64(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.SInt32:
+ {
+ ICollection<int> output = (ICollection<int>)list;
+ int tmp = 0;
+ do
+ {
+ ReadSInt32(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.SInt64:
+ {
+ ICollection<long> output = (ICollection<long>)list;
+ long tmp = 0;
+ do
+ {
+ ReadSInt64(ref tmp);
+ output.Add(tmp);
+ }
+ while (ContinueArray(fieldTag, packed));
+ }
+ break;
+ case FieldType.Group:
+ throw new ArgumentException("ReadPrimitiveField() cannot handle nested groups.");
+ case FieldType.Message:
+ throw new ArgumentException("ReadPrimitiveField() cannot handle embedded messages.");
+ // We don't handle enums because we don't know what to do if the
+ // value is not recognized.
+ case FieldType.Enum:
+ throw new ArgumentException("ReadPrimitiveField() cannot handle enums.");
+ default:
+ throw new ArgumentOutOfRangeException("Invalid field type " + fieldType);
}
}
@@ -601,7 +838,7 @@ namespace Google.ProtocolBuffers
unknown.Add(unkval);
}
}
- while (ContinueArray(fieldTag));
+ while (ContinueArray(fieldTag, false));
}
}
@@ -645,7 +882,7 @@ namespace Google.ProtocolBuffers
unknown.Add(unkval);
}
}
- while (ContinueArray(fieldTag));
+ while (ContinueArray(fieldTag, false));
}
}
@@ -658,7 +895,7 @@ namespace Google.ProtocolBuffers
ReadMessage(builder, registry);
list.Add((T)builder.WeakBuildPartial());
}
- while (ContinueArray(fieldTag));
+ while (ContinueArray(fieldTag, false));
}
[CLSCompliant(false)]
@@ -670,7 +907,7 @@ namespace Google.ProtocolBuffers
ReadGroup(WireFormat.GetTagFieldNumber(fieldTag), builder, registry);
list.Add((T)builder.WeakBuildPartial());
}
- while (ContinueArray(fieldTag));
+ while (ContinueArray(fieldTag, false));
}
/// <summary>
diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs
index 0bc4a462..37355412 100644
--- a/src/ProtocolBuffers/CodedOutputStream.cs
+++ b/src/ProtocolBuffers/CodedOutputStream.cs
@@ -40,6 +40,7 @@ using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
+using Google.ProtocolBuffers.Collections;
using Google.ProtocolBuffers.Descriptors;
namespace Google.ProtocolBuffers
@@ -272,7 +273,7 @@ namespace Google.ProtocolBuffers
WriteRawVarint32(value);
}
- public void WriteEnum(int fieldNumber, string fieldName, int value, string textValue)
+ public void WriteEnum(int fieldNumber, string fieldName, int value, object textValue)
{
WriteTag(fieldNumber, WireFormat.WireType.Varint);
WriteRawVarint32((uint) value);
@@ -349,11 +350,14 @@ namespace Google.ProtocolBuffers
WriteBool(fieldNumber, fieldName, value);
break;
case FieldType.Enum:
- foreach (T value in list)
+ if (default(T) is System.Enum)
+ {
+ foreach (int value in ((ICastArray)list).CastArray<int>())
+ WriteEnum(fieldNumber, fieldName, value, null/*not used*/);
+ }
+ else
{
- if (value is System.Enum)
- WriteEnum(fieldNumber, fieldName, ((IConvertible)value).ToInt32(CultureInfo.InvariantCulture), null/*not used*/);
- else
+ foreach (T value in list)
WriteEnum(fieldNumber, fieldName, ((IEnumLite)value).Number, null/*not used*/);
}
break;
@@ -449,11 +453,14 @@ namespace Google.ProtocolBuffers
WriteBoolNoTag(value);
break;
case FieldType.Enum:
- foreach (T value in list)
+ if (default(T) is System.Enum)
+ {
+ foreach (int value in ((ICastArray)list).CastArray<int>())
+ WriteEnumNoTag(value);
+ }
+ else
{
- if (value is System.Enum)
- WriteEnumNoTag(((IConvertible)value).ToInt32(CultureInfo.InvariantCulture));
- else
+ foreach (T value in list)
WriteEnumNoTag(((IEnumLite)value).Number);
}
break;
@@ -529,7 +536,7 @@ namespace Google.ProtocolBuffers
break;
case FieldType.Enum:
if (value is System.Enum)
- WriteEnum(fieldNumber, fieldName, ((IConvertible)value).ToInt32(CultureInfo.InvariantCulture), null/*not used*/);
+ WriteEnum(fieldNumber, fieldName, (int)value, null/*not used*/);
else
WriteEnum(fieldNumber, fieldName, ((IEnumLite)value).Number, null/*not used*/);
break;
@@ -593,7 +600,7 @@ namespace Google.ProtocolBuffers
break;
case FieldType.Enum:
if (value is System.Enum)
- WriteEnumNoTag(((IConvertible)value).ToInt32(CultureInfo.InvariantCulture));
+ WriteEnumNoTag((int)value);
else
WriteEnumNoTag(((IEnumLite)value).Number);
break;
diff --git a/src/ProtocolBuffers/Collections/IPopsicleList.cs b/src/ProtocolBuffers/Collections/IPopsicleList.cs
index 7f6fd8bc..a1a75815 100644
--- a/src/ProtocolBuffers/Collections/IPopsicleList.cs
+++ b/src/ProtocolBuffers/Collections/IPopsicleList.cs
@@ -47,4 +47,12 @@ namespace Google.ProtocolBuffers.Collections
{
void Add(IEnumerable<T> collection);
}
+
+ /// <summary>
+ /// Used to efficiently cast the elements of enumerations
+ /// </summary>
+ internal interface ICastArray
+ {
+ IEnumerable<TItemType> CastArray<TItemType>();
+ }
} \ No newline at end of file
diff --git a/src/ProtocolBuffers/Collections/PopsicleList.cs b/src/ProtocolBuffers/Collections/PopsicleList.cs
index 33324303..48161e82 100644
--- a/src/ProtocolBuffers/Collections/PopsicleList.cs
+++ b/src/ProtocolBuffers/Collections/PopsicleList.cs
@@ -40,10 +40,12 @@ namespace Google.ProtocolBuffers.Collections
/// to be made read-only (with the <see cref="MakeReadOnly" /> method),
/// after which any modifying methods throw <see cref="NotSupportedException" />.
/// </summary>
- public sealed class PopsicleList<T> : IPopsicleList<T>
+ public sealed class PopsicleList<T> : IPopsicleList<T>, ICastArray
{
- private readonly List<T> items = new List<T>();
- private bool readOnly = false;
+ private static readonly IEnumerable<T> EmptySet = new T[0];
+
+ private List<T> items;
+ private bool readOnly;
/// <summary>
/// Makes this list read-only ("freezes the popsicle"). From this
@@ -57,7 +59,7 @@ namespace Google.ProtocolBuffers.Collections
public int IndexOf(T item)
{
- return items.IndexOf(item);
+ return items == null ? -1 : items.IndexOf(item);
}
public void Insert(int index, T item)
@@ -74,7 +76,7 @@ namespace Google.ProtocolBuffers.Collections
public T this[int index]
{
- get { return items[index]; }
+ get { if (items == null) throw new ArgumentOutOfRangeException(); return items[index]; }
set
{
ValidateModification();
@@ -96,17 +98,18 @@ namespace Google.ProtocolBuffers.Collections
public bool Contains(T item)
{
- return items.Contains(item);
+ return items == null ? false : items.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
- items.CopyTo(array, arrayIndex);
+ if (items != null)
+ items.CopyTo(array, arrayIndex);
}
public int Count
{
- get { return items.Count; }
+ get { return items == null ? 0 : items.Count; }
}
public bool IsReadOnly
@@ -120,18 +123,9 @@ namespace Google.ProtocolBuffers.Collections
return items.Remove(item);
}
- public void Add(IEnumerable<T> collection)
- {
- if (readOnly)
- {
- throw new NotSupportedException("List is read-only");
- }
- items.AddRange(collection);
- }
-
public IEnumerator<T> GetEnumerator()
{
- return items.GetEnumerator();
+ return items == null ? EmptySet.GetEnumerator() : items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
@@ -139,12 +133,32 @@ namespace Google.ProtocolBuffers.Collections
return GetEnumerator();
}
+ public void Add(IEnumerable<T> collection)
+ {
+ if (readOnly)
+ {
+ throw new NotSupportedException("List is read-only");
+ }
+ if (items == null)
+ items = new List<T>();
+ items.AddRange(collection);
+ }
+
private void ValidateModification()
{
if (readOnly)
{
throw new NotSupportedException("List is read-only");
}
+ if (items == null)
+ items = new List<T>();
+ }
+
+ IEnumerable<TItemType> ICastArray.CastArray<TItemType>()
+ {
+ if (items == null)
+ return new TItemType[0];
+ return (TItemType[])(object)items.ToArray();
}
}
} \ No newline at end of file
diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
index 8bcbde7f..e3308065 100644
--- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
+++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
@@ -178,7 +178,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int MultipleFilesFieldNumber = 4;
private bool hasMultipleFiles;
- private bool multipleFiles_ = false;
+ private bool multipleFiles_;
public bool HasMultipleFiles {
get { return hasMultipleFiles; }
}
@@ -188,7 +188,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int NestClassesFieldNumber = 5;
private bool hasNestClasses;
- private bool nestClasses_ = false;
+ private bool nestClasses_;
public bool HasNestClasses {
get { return hasNestClasses; }
}
@@ -198,7 +198,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int CodeContractsFieldNumber = 6;
private bool hasCodeContracts;
- private bool codeContracts_ = false;
+ private bool codeContracts_;
public bool HasCodeContracts {
get { return hasCodeContracts; }
}
@@ -208,7 +208,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int ExpandNamespaceDirectoriesFieldNumber = 7;
private bool hasExpandNamespaceDirectories;
- private bool expandNamespaceDirectories_ = false;
+ private bool expandNamespaceDirectories_;
public bool HasExpandNamespaceDirectories {
get { return hasExpandNamespaceDirectories; }
}
@@ -258,7 +258,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int IgnoreGoogleProtobufFieldNumber = 224;
private bool hasIgnoreGoogleProtobuf;
- private bool ignoreGoogleProtobuf_ = false;
+ private bool ignoreGoogleProtobuf_;
public bool HasIgnoreGoogleProtobuf {
get { return hasIgnoreGoogleProtobuf; }
}
@@ -322,7 +322,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
output.WriteBool(224, field_names[4], IgnoreGoogleProtobuf);
}
if (hasServiceGeneratorType) {
- output.WriteEnum(225, field_names[10], (int) ServiceGeneratorType, ServiceGeneratorType.ToString());
+ output.WriteEnum(225, field_names[10], (int) ServiceGeneratorType, ServiceGeneratorType);
}
UnknownFields.WriteTo(output);
}
@@ -1372,7 +1372,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int DispatchIdFieldNumber = 1;
private bool hasDispatchId;
- private int dispatchId_ = 0;
+ private int dispatchId_;
public bool HasDispatchId {
get { return hasDispatchId; }
}
diff --git a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
index 4507f3f1..ee6ac94c 100644
--- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
@@ -1229,7 +1229,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int StartFieldNumber = 1;
private bool hasStart;
- private int start_ = 0;
+ private int start_;
public bool HasStart {
get { return hasStart; }
}
@@ -1239,7 +1239,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int EndFieldNumber = 2;
private bool hasEnd;
- private int end_ = 0;
+ private int end_;
public bool HasEnd {
get { return hasEnd; }
}
@@ -2173,7 +2173,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int NumberFieldNumber = 3;
private bool hasNumber;
- private int number_ = 0;
+ private int number_;
public bool HasNumber {
get { return hasNumber; }
}
@@ -2263,10 +2263,10 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
output.WriteInt32(3, field_names[4], Number);
}
if (hasLabel) {
- output.WriteEnum(4, field_names[2], (int) Label, Label.ToString());
+ output.WriteEnum(4, field_names[2], (int) Label, Label);
}
if (hasType) {
- output.WriteEnum(5, field_names[6], (int) Type, Type.ToString());
+ output.WriteEnum(5, field_names[6], (int) Type, Type);
}
if (hasTypeName) {
output.WriteString(6, field_names[7], TypeName);
@@ -3119,7 +3119,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int NumberFieldNumber = 2;
private bool hasNumber;
- private int number_ = 0;
+ private int number_;
public bool HasNumber {
get { return hasNumber; }
}
@@ -4258,7 +4258,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int JavaMultipleFilesFieldNumber = 10;
private bool hasJavaMultipleFiles;
- private bool javaMultipleFiles_ = false;
+ private bool javaMultipleFiles_;
public bool HasJavaMultipleFiles {
get { return hasJavaMultipleFiles; }
}
@@ -4339,7 +4339,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
output.WriteString(8, field_names[3], JavaOuterClassname);
}
if (hasOptimizeFor) {
- output.WriteEnum(9, field_names[5], (int) OptimizeFor, OptimizeFor.ToString());
+ output.WriteEnum(9, field_names[5], (int) OptimizeFor, OptimizeFor);
}
if (hasJavaMultipleFiles) {
output.WriteBool(10, field_names[2], JavaMultipleFiles);
@@ -4805,7 +4805,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int MessageSetWireFormatFieldNumber = 1;
private bool hasMessageSetWireFormat;
- private bool messageSetWireFormat_ = false;
+ private bool messageSetWireFormat_;
public bool HasMessageSetWireFormat {
get { return hasMessageSetWireFormat; }
}
@@ -4815,7 +4815,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int NoStandardDescriptorAccessorFieldNumber = 2;
private bool hasNoStandardDescriptorAccessor;
- private bool noStandardDescriptorAccessor_ = false;
+ private bool noStandardDescriptorAccessor_;
public bool HasNoStandardDescriptorAccessor {
get { return hasNoStandardDescriptorAccessor; }
}
@@ -5183,7 +5183,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int PackedFieldNumber = 2;
private bool hasPacked;
- private bool packed_ = false;
+ private bool packed_;
public bool HasPacked {
get { return hasPacked; }
}
@@ -5193,7 +5193,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int DeprecatedFieldNumber = 3;
private bool hasDeprecated;
- private bool deprecated_ = false;
+ private bool deprecated_;
public bool HasDeprecated {
get { return hasDeprecated; }
}
@@ -5238,7 +5238,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
string[] field_names = _fieldOptionsFieldNames;
pb::ExtendableMessage<FieldOptions, FieldOptions.Builder>.ExtensionWriter extensionWriter = CreateExtensionWriter(this);
if (hasCtype) {
- output.WriteEnum(1, field_names[0], (int) Ctype, Ctype.ToString());
+ output.WriteEnum(1, field_names[0], (int) Ctype, Ctype);
}
if (hasPacked) {
output.WriteBool(2, field_names[3], Packed);
@@ -6738,7 +6738,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int IsExtensionFieldNumber = 2;
private bool hasIsExtension;
- private bool isExtension_ = false;
+ private bool isExtension_;
public bool HasIsExtension {
get { return hasIsExtension; }
}
@@ -7009,7 +7009,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int PositiveIntValueFieldNumber = 4;
private bool hasPositiveIntValue;
- private ulong positiveIntValue_ = 0UL;
+ private ulong positiveIntValue_;
public bool HasPositiveIntValue {
get { return hasPositiveIntValue; }
}
@@ -7020,7 +7020,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int NegativeIntValueFieldNumber = 5;
private bool hasNegativeIntValue;
- private long negativeIntValue_ = 0L;
+ private long negativeIntValue_;
public bool HasNegativeIntValue {
get { return hasNegativeIntValue; }
}
@@ -7030,7 +7030,7 @@ namespace Google.ProtocolBuffers.DescriptorProtos {
public const int DoubleValueFieldNumber = 6;
private bool hasDoubleValue;
- private double doubleValue_ = 0D;
+ private double doubleValue_;
public bool HasDoubleValue {
get { return hasDoubleValue; }
}
diff --git a/src/ProtocolBuffers/ICodedInputStream.cs b/src/ProtocolBuffers/ICodedInputStream.cs
index f385454b..f4c66227 100644
--- a/src/ProtocolBuffers/ICodedInputStream.cs
+++ b/src/ProtocolBuffers/ICodedInputStream.cs
@@ -144,6 +144,13 @@ namespace Google.ProtocolBuffers
/// type is numberic, it will read a packed array.
/// </summary>
[CLSCompliant(false)]
+ void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
+
+ /// <summary>
+ /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the
+ /// type is numberic, it will read a packed array.
+ /// </summary>
+ [CLSCompliant(false)]
void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list);
/// <summary>
diff --git a/src/ProtocolBuffers/ICodedOutputStream.cs b/src/ProtocolBuffers/ICodedOutputStream.cs
index db7ea6e1..6408d98c 100644
--- a/src/ProtocolBuffers/ICodedOutputStream.cs
+++ b/src/ProtocolBuffers/ICodedOutputStream.cs
@@ -70,7 +70,7 @@ namespace Google.ProtocolBuffers
[CLSCompliant(false)]
void WriteUInt32(int fieldNumber, string fieldName, uint value);
- void WriteEnum(int fieldNumber, string fieldName, int value, string textValue);
+ void WriteEnum(int fieldNumber, string fieldName, int value, object rawValue);
void WriteSFixed32(int fieldNumber, string fieldName, int value);
void WriteSFixed64(int fieldNumber, string fieldName, long value);
void WriteSInt32(int fieldNumber, string fieldName, int value);