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
diff --git a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
index 8bcbde7..e330806 100644
--- a/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
+++ b/src/ProtocolBuffers/DescriptorProtos/CSharpOptions.cs
@@ -178,7 +178,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 4507f3f..ee6ac94 100644
--- a/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+++ b/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
@@ -1229,7 +1229,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
public const int DoubleValueFieldNumber = 6;
private bool hasDoubleValue;
- private double doubleValue_ = 0D;
+ private double doubleValue_;
public bool HasDoubleValue {
get { return hasDoubleValue; }
}