aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers
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 /csharp/src/ProtocolBuffers
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 'csharp/src/ProtocolBuffers')
-rw-r--r--csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs220
-rw-r--r--csharp/src/ProtocolBuffers/CodedOutputStream.cs617
-rw-r--r--csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs458
3 files changed, 461 insertions, 834 deletions
diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
index aba5a1a2..e3d2b068 100644
--- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
+++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs
@@ -47,193 +47,13 @@ namespace Google.Protobuf
public sealed partial class CodedOutputStream
{
private const int LittleEndian64Size = 8;
- private const int LittleEndian32Size = 4;
+ private const int LittleEndian32Size = 4;
/// <summary>
/// Compute the number of bytes that would be needed to encode a
/// double field, including the tag.
/// </summary>
- public static int ComputeDoubleSize(int fieldNumber, double value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// float field, including the tag.
- /// </summary>
- public static int ComputeFloatSize(int fieldNumber, float value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// uint64 field, including the tag.
- /// </summary>
- public static int ComputeUInt64Size(int fieldNumber, ulong value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// int64 field, including the tag.
- /// </summary>
- public static int ComputeInt64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size((ulong) value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// int32 field, including the tag.
- /// </summary>
- public static int ComputeInt32Size(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + ComputeInt32SizeNoTag(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// fixed64 field, including the tag.
- /// </summary>
- public static int ComputeFixed64Size(int fieldNumber, ulong value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// fixed32 field, including the tag.
- /// </summary>
- public static int ComputeFixed32Size(int fieldNumber, uint value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// bool field, including the tag.
- /// </summary>
- public static int ComputeBoolSize(int fieldNumber, bool value)
- {
- return ComputeTagSize(fieldNumber) + 1;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// string field, including the tag.
- /// </summary>
- public static int ComputeStringSize(int fieldNumber, String value)
- {
- int byteArraySize = UTF8.GetByteCount(value);
- return ComputeTagSize(fieldNumber) +
- ComputeRawVarint32Size((uint) byteArraySize) +
- byteArraySize;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// group field, including the tag.
- /// </summary>
- public static int ComputeGroupSize(int fieldNumber, IMessage value)
- {
- return ComputeTagSize(fieldNumber)*2 + value.CalculateSize();
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// group field represented by an UnknownFieldSet, including the tag.
- /// </summary>
- [Obsolete]
- public static int ComputeUnknownGroupSize(int fieldNumber,
- IMessage value)
- {
- return ComputeTagSize(fieldNumber)*2 + value.CalculateSize();
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// embedded message field, including the tag.
- /// </summary>
- public static int ComputeMessageSize(int fieldNumber, IMessage value)
- {
- int size = value.CalculateSize();
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) size) + size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// bytes field, including the tag.
- /// </summary>
- public static int ComputeBytesSize(int fieldNumber, ByteString value)
- {
- return ComputeTagSize(fieldNumber) +
- ComputeRawVarint32Size((uint) value.Length) +
- value.Length;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// uint32 field, including the tag.
- /// </summary>
- public static int ComputeUInt32Size(int fieldNumber, uint value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// enum field, including the tag. The caller is responsible for
- /// converting the enum value to its numeric value.
- /// </summary>
- public static int ComputeEnumSize(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + ComputeEnumSizeNoTag(value);
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sfixed32 field, including the tag.
- /// </summary>
- public static int ComputeSFixed32Size(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian32Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sfixed64 field, including the tag.
- /// </summary>
- public static int ComputeSFixed64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + LittleEndian64Size;
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sint32 field, including the tag.
- /// </summary>
- public static int ComputeSInt32Size(int fieldNumber, int value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size(EncodeZigZag32(value));
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode an
- /// sint64 field, including the tag.
- /// </summary>
- public static int ComputeSInt64Size(int fieldNumber, long value)
- {
- return ComputeTagSize(fieldNumber) + ComputeRawVarint64Size(EncodeZigZag64(value));
- }
-
- /// <summary>
- /// Compute the number of bytes that would be needed to encode a
- /// double field, including the tag.
- /// </summary>
- public static int ComputeDoubleSizeNoTag(double value)
+ public static int ComputeDoubleSize(double value)
{
return LittleEndian64Size;
}
@@ -242,7 +62,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// float field, including the tag.
/// </summary>
- public static int ComputeFloatSizeNoTag(float value)
+ public static int ComputeFloatSize(float value)
{
return LittleEndian32Size;
}
@@ -251,7 +71,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// uint64 field, including the tag.
/// </summary>
- public static int ComputeUInt64SizeNoTag(ulong value)
+ public static int ComputeUInt64Size(ulong value)
{
return ComputeRawVarint64Size(value);
}
@@ -260,7 +80,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// int64 field, including the tag.
/// </summary>
- public static int ComputeInt64SizeNoTag(long value)
+ public static int ComputeInt64Size(long value)
{
return ComputeRawVarint64Size((ulong) value);
}
@@ -269,7 +89,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// int32 field, including the tag.
/// </summary>
- public static int ComputeInt32SizeNoTag(int value)
+ public static int ComputeInt32Size(int value)
{
if (value >= 0)
{
@@ -286,7 +106,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// fixed64 field, including the tag.
/// </summary>
- public static int ComputeFixed64SizeNoTag(ulong value)
+ public static int ComputeFixed64Size(ulong value)
{
return LittleEndian64Size;
}
@@ -295,7 +115,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// fixed32 field, including the tag.
/// </summary>
- public static int ComputeFixed32SizeNoTag(uint value)
+ public static int ComputeFixed32Size(uint value)
{
return LittleEndian32Size;
}
@@ -304,7 +124,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// bool field, including the tag.
/// </summary>
- public static int ComputeBoolSizeNoTag(bool value)
+ public static int ComputeBoolSize(bool value)
{
return 1;
}
@@ -313,7 +133,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// string field, including the tag.
/// </summary>
- public static int ComputeStringSizeNoTag(String value)
+ public static int ComputeStringSize(String value)
{
int byteArraySize = UTF8.GetByteCount(value);
return ComputeRawVarint32Size((uint) byteArraySize) +
@@ -324,7 +144,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// group field, including the tag.
/// </summary>
- public static int ComputeGroupSizeNoTag(IMessage value)
+ public static int ComputeGroupSize(IMessage value)
{
return value.CalculateSize();
}
@@ -333,7 +153,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// embedded message field, including the tag.
/// </summary>
- public static int ComputeMessageSizeNoTag(IMessage value)
+ public static int ComputeMessageSize(IMessage value)
{
int size = value.CalculateSize();
return ComputeRawVarint32Size((uint) size) + size;
@@ -343,7 +163,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// bytes field, including the tag.
/// </summary>
- public static int ComputeBytesSizeNoTag(ByteString value)
+ public static int ComputeBytesSize(ByteString value)
{
return ComputeRawVarint32Size((uint) value.Length) +
value.Length;
@@ -353,7 +173,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode a
/// uint32 field, including the tag.
/// </summary>
- public static int ComputeUInt32SizeNoTag(uint value)
+ public static int ComputeUInt32Size(uint value)
{
return ComputeRawVarint32Size(value);
}
@@ -363,17 +183,17 @@ namespace Google.Protobuf
/// enum field, including the tag. The caller is responsible for
/// converting the enum value to its numeric value.
/// </summary>
- public static int ComputeEnumSizeNoTag(int value)
+ public static int ComputeEnumSize(int value)
{
// Currently just a pass-through, but it's nice to separate it logically.
- return ComputeInt32SizeNoTag(value);
+ return ComputeInt32Size(value);
}
/// <summary>
/// Compute the number of bytes that would be needed to encode an
/// sfixed32 field, including the tag.
/// </summary>
- public static int ComputeSFixed32SizeNoTag(int value)
+ public static int ComputeSFixed32Size(int value)
{
return LittleEndian32Size;
}
@@ -382,7 +202,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sfixed64 field, including the tag.
/// </summary>
- public static int ComputeSFixed64SizeNoTag(long value)
+ public static int ComputeSFixed64Size(long value)
{
return LittleEndian64Size;
}
@@ -391,7 +211,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sint32 field, including the tag.
/// </summary>
- public static int ComputeSInt32SizeNoTag(int value)
+ public static int ComputeSInt32Size(int value)
{
return ComputeRawVarint32Size(EncodeZigZag32(value));
}
@@ -400,7 +220,7 @@ namespace Google.Protobuf
/// Compute the number of bytes that would be needed to encode an
/// sint64 field, including the tag.
/// </summary>
- public static int ComputeSInt64SizeNoTag(long value)
+ public static int ComputeSInt64Size(long value)
{
return ComputeRawVarint64Size(EncodeZigZag64(value));
}
diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.cs
index bc3ed7d7..6c135e86 100644
--- a/csharp/src/ProtocolBuffers/CodedOutputStream.cs
+++ b/csharp/src/ProtocolBuffers/CodedOutputStream.cs
@@ -143,248 +143,12 @@ namespace Google.Protobuf
}
}
- #region Writing of tags and fields
- /// <summary>
- /// Writes a double field value, including tag, to the stream.
- /// </summary>
- public void WriteDouble(int fieldNumber, double value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteDoubleNoTag(value);
- }
-
- /// <summary>
- /// Writes a float field value, including tag, to the stream.
- /// </summary>
- public void WriteFloat(int fieldNumber, float value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteFloatNoTag(value);
- }
-
- /// <summary>
- /// Writes a uint64 field value, including tag, to the stream.
- /// </summary>
- public void WriteUInt64(int fieldNumber, ulong value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64(value);
- }
-
- /// <summary>
- /// Writes an int64 field value, including tag, to the stream.
- /// </summary>
- public void WriteInt64(int fieldNumber, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64((ulong) value);
- }
-
- /// <summary>
- /// Writes an int32 field value, including tag, to the stream.
- /// </summary>
- public void WriteInt32(int fieldNumber, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- if (value >= 0)
- {
- WriteRawVarint32((uint) value);
- }
- else
- {
- // Must sign-extend.
- WriteRawVarint64((ulong) value);
- }
- }
-
- /// <summary>
- /// Writes a fixed64 field value, including tag, to the stream.
- /// </summary>
- public void WriteFixed64(int fieldNumber, ulong value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteRawLittleEndian64(value);
- }
-
- /// <summary>
- /// Writes a fixed32 field value, including tag, to the stream.
- /// </summary>
- public void WriteFixed32(int fieldNumber, uint value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteRawLittleEndian32(value);
- }
-
- /// <summary>
- /// Writes a bool field value, including tag, to the stream.
- /// </summary>
- public void WriteBool(int fieldNumber, bool value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawByte(value ? (byte) 1 : (byte) 0);
- }
-
- /// <summary>
- /// Writes a string field value, including tag, to the stream.
- /// </summary>
- public void WriteString(int fieldNumber, string value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- // Optimise the case where we have enough space to write
- // the string directly to the buffer, which should be common.
- int length = UTF8.GetByteCount(value);
- WriteRawVarint32((uint) length);
- if (limit - position >= length)
- {
- if (length == value.Length) // Must be all ASCII...
- {
- for (int i = 0; i < length; i++)
- {
- buffer[position + i] = (byte)value[i];
- }
- }
- else
- {
- UTF8.GetBytes(value, 0, value.Length, buffer, position);
- }
- position += length;
- }
- else
- {
- byte[] bytes = UTF8.GetBytes(value);
- WriteRawBytes(bytes);
- }
- }
-
- /// <summary>
- /// Writes a group field value, including tag, to the stream.
- /// </summary>
- public void WriteGroup(int fieldNumber, IMessage value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.StartGroup);
- value.WriteTo(this);
- WriteTag(fieldNumber, WireFormat.WireType.EndGroup);
- }
-
- public void WriteMessage(int fieldNumber, IMessage value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) value.CalculateSize());
- value.WriteTo(this);
- }
-
- public void WriteBytes(int fieldNumber, ByteString value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
- WriteRawVarint32((uint) value.Length);
- value.WriteRawBytesTo(this);
- }
-
- public void WriteUInt32(int fieldNumber, uint value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint32(value);
- }
-
- public void WriteEnum(int fieldNumber, int value)
- {
- // Currently just a pass-through, but it's nice to separate it logically from WriteInt32.
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteInt32NoTag(value);
- }
-
- public void WriteSFixed32(int fieldNumber, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
- WriteRawLittleEndian32((uint) value);
- }
-
- public void WriteSFixed64(int fieldNumber, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
- WriteRawLittleEndian64((ulong) value);
- }
-
- public void WriteSInt32(int fieldNumber, int value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint32(EncodeZigZag32(value));
- }
-
- public void WriteSInt64(int fieldNumber, long value)
- {
- WriteTag(fieldNumber, WireFormat.WireType.Varint);
- WriteRawVarint64(EncodeZigZag64(value));
- }
- #endregion
-
#region Writing of values without tags
- // TODO(jonskeet): Remove this?
- public void WriteFieldNoTag(FieldType fieldType, object value)
- {
- switch (fieldType)
- {
- case FieldType.String:
- WriteStringNoTag((string) value);
- break;
- case FieldType.Message:
- WriteMessageNoTag((IMessage) value);
- break;
- case FieldType.Group:
- WriteGroupNoTag((IMessage) value);
- break;
- case FieldType.Bytes:
- WriteBytesNoTag((ByteString) value);
- break;
- case FieldType.Bool:
- WriteBoolNoTag((bool) value);
- break;
- case FieldType.Enum:
- WriteEnumNoTag((int) value);
- break;
- case FieldType.Int32:
- WriteInt32NoTag((int) value);
- break;
- case FieldType.Int64:
- WriteInt64NoTag((long) value);
- break;
- case FieldType.UInt32:
- WriteUInt32NoTag((uint) value);
- break;
- case FieldType.UInt64:
- WriteUInt64NoTag((ulong) value);
- break;
- case FieldType.SInt32:
- WriteSInt32NoTag((int) value);
- break;
- case FieldType.SInt64:
- WriteSInt64NoTag((long) value);
- break;
- case FieldType.Fixed32:
- WriteFixed32NoTag((uint) value);
- break;
- case FieldType.Fixed64:
- WriteFixed64NoTag((ulong) value);
- break;
- case FieldType.SFixed32:
- WriteSFixed32NoTag((int) value);
- break;
- case FieldType.SFixed64:
- WriteSFixed64NoTag((long) value);
- break;
- case FieldType.Double:
- WriteDoubleNoTag((double) value);
- break;
- case FieldType.Float:
- WriteFloatNoTag((float) value);
- break;
- }
- }
/// <summary>
/// Writes a double field value, including tag, to the stream.
/// </summary>
- public void WriteDoubleNoTag(double value)
+ public void WriteDouble(double value)
{
WriteRawLittleEndian64((ulong)FrameworkPortability.DoubleToInt64(value));
}
@@ -392,7 +156,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a float field value, without a tag, to the stream.
/// </summary>
- public void WriteFloatNoTag(float value)
+ public void WriteFloat(float value)
{
byte[] rawBytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
@@ -416,7 +180,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a uint64 field value, without a tag, to the stream.
/// </summary>
- public void WriteUInt64NoTag(ulong value)
+ public void WriteUInt64(ulong value)
{
WriteRawVarint64(value);
}
@@ -424,7 +188,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int64 field value, without a tag, to the stream.
/// </summary>
- public void WriteInt64NoTag(long value)
+ public void WriteInt64(long value)
{
WriteRawVarint64((ulong) value);
}
@@ -432,7 +196,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes an int32 field value, without a tag, to the stream.
/// </summary>
- public void WriteInt32NoTag(int value)
+ public void WriteInt32(int value)
{
if (value >= 0)
{
@@ -448,7 +212,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed64 field value, without a tag, to the stream.
/// </summary>
- public void WriteFixed64NoTag(ulong value)
+ public void WriteFixed64(ulong value)
{
WriteRawLittleEndian64(value);
}
@@ -456,7 +220,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a fixed32 field value, without a tag, to the stream.
/// </summary>
- public void WriteFixed32NoTag(uint value)
+ public void WriteFixed32(uint value)
{
WriteRawLittleEndian32(value);
}
@@ -464,7 +228,7 @@ namespace Google.Protobuf
/// <summary>
/// Writes a bool field value, without a tag, to the stream.
/// </summary>
- public void WriteBoolNoTag(bool value)
+ public void WriteBool(bool value)
{
WriteRawByte(value ? (byte) 1 : (byte) 0);
}
@@ -472,485 +236,440 @@ namespace Google.Protobuf
/// <summary>
/// Writes a string field value, without a tag, to the stream.
/// </summary>
- public void WriteStringNoTag(string value)
+ public void WriteString(string value)
{
// Optimise the case where we have enough space to write
// the string directly to the buffer, which should be common.
- int length = Encoding.UTF8.GetByteCount(value);
- WriteRawVarint32((uint) length);
+ int length = UTF8.GetByteCount(value);
+ WriteRawVarint32((uint)length);
if (limit - position >= length)
{
- Encoding.UTF8.GetBytes(value, 0, value.Length, buffer, position);
+ if (length == value.Length) // Must be all ASCII...
+ {
+ for (int i = 0; i < length; i++)
+ {
+ buffer[position + i] = (byte)value[i];
+ }
+ }
+ else
+ {
+ UTF8.GetBytes(value, 0, value.Length, buffer, position);
+ }
position += length;
}
else
{
- byte[] bytes = Encoding.UTF8.GetBytes(value);
+ byte[] bytes = UTF8.GetBytes(value);
WriteRawBytes(bytes);
}
}
- /// <summary>
- /// Writes a group field value, without a tag, to the stream.
- /// </summary>
- public void WriteGroupNoTag(IMessage value)
- {
- value.WriteTo(this);
- }
-
- public void WriteMessageNoTag(IMessage value)
+ public void WriteMessage(IMessage value)
{
WriteRawVarint32((uint) value.CalculateSize());
value.WriteTo(this);
}
- public void WriteBytesNoTag(ByteString value)
+ public void WriteBytes(ByteString value)
{
WriteRawVarint32((uint) value.Length);
value.WriteRawBytesTo(this);
}
- public void WriteUInt32NoTag(uint value)
+ public void WriteUInt32(uint value)
{
WriteRawVarint32(value);
}
- public void WriteEnumNoTag(int value)
+ public void WriteEnum(int value)
{
- WriteInt32NoTag(value);
+ WriteInt32(value);
}
- public void WriteSFixed32NoTag(int value)
+ public void WriteSFixed32(int value)
{
WriteRawLittleEndian32((uint) value);
}
- public void WriteSFixed64NoTag(long value)
+ public void WriteSFixed64(long value)
{
WriteRawLittleEndian64((ulong) value);
}
- public void WriteSInt32NoTag(int value)
+ public void WriteSInt32(int value)
{
WriteRawVarint32(EncodeZigZag32(value));
}
- public void WriteSInt64NoTag(long value)
+ public void WriteSInt64(long value)
{
WriteRawVarint64(EncodeZigZag64(value));
}
#endregion
- #region Write array members
+ #region Write array members, with fields.
public void WriteMessageArray<T>(int fieldNumber, RepeatedField<T> list)
where T : IMessage
{
- if (list.Count == 0)
- {
- return;
- }
foreach (T value in list)
{
- WriteMessage(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteMessage(value);
}
}
public void WriteStringArray(int fieldNumber, RepeatedField<string> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteString(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteString(value);
}
}
public void WriteBytesArray(int fieldNumber, RepeatedField<ByteString> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteBytes(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ WriteBytes(value);
}
}
public void WriteBoolArray(int fieldNumber, RepeatedField<bool> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteBool(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteBool(value);
}
}
public void WriteInt32Array(int fieldNumber, RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteInt32(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteInt32(value);
}
}
public void WriteSInt32Array(int fieldNumber, RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteSInt32(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteSInt32(value);
}
}
public void WriteUInt32Array(int fieldNumber, RepeatedField<uint> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteUInt32(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteUInt32(value);
}
}
public void WriteFixed32Array(int fieldNumber, RepeatedField<uint> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteFixed32(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteFixed32(value);
}
}
public void WriteSFixed32Array(int fieldNumber, RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteSFixed32(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteSFixed32(value);
}
}
public void WriteInt64Array(int fieldNumber, RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteInt64(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteInt64(value);
}
}
public void WriteSInt64Array(int fieldNumber, RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteSInt64(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteSInt64(value);
}
}
public void WriteUInt64Array(int fieldNumber, RepeatedField<ulong> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteUInt64(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteUInt64(value);
}
}
public void WriteFixed64Array(int fieldNumber, RepeatedField<ulong> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteFixed64(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteFixed64(value);
}
}
public void WriteSFixed64Array(int fieldNumber, RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteSFixed64(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteSFixed64(value);
}
}
public void WriteDoubleArray(int fieldNumber, RepeatedField<double> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteDouble(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed64);
+ WriteDouble(value);
}
}
public void WriteFloatArray(int fieldNumber, RepeatedField<float> list)
{
- if (list.Count == 0)
- {
- return;
- }
foreach (var value in list)
{
- WriteFloat(fieldNumber, value);
+ WriteTag(fieldNumber, WireFormat.WireType.Fixed32);
+ WriteFloat(value);
}
}
public void WriteEnumArray<T>(int fieldNumber, RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
- if (list.Count == 0)
- {
- return;
- }
// Bit of a hack, to access the values as ints
var iterator = list.GetInt32Enumerator();
while (iterator.MoveNext())
{
- WriteEnum(fieldNumber, iterator.Current);
+ WriteTag(fieldNumber, WireFormat.WireType.Varint);
+ WriteEnum(iterator.Current);
}
}
#endregion
+ #region Raw tag writing
+ /// <summary>
+ /// Encodes and writes a tag.
+ /// </summary>
+ public void WriteTag(int fieldNumber, WireFormat.WireType type)
+ {
+ WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
+ }
+
+ /// <summary>
+ /// Writes the given single-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1)
+ {
+ WriteRawByte(b1);
+ }
+
+ /// <summary>
+ /// Writes the given two-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2)
+ {
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ }
+
+ /// <summary>
+ /// Writes the given three-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3)
+ {
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
+ }
+
+ /// <summary>
+ /// Writes the given four-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3, byte b4)
+ {
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
+ WriteRawByte(b4);
+ }
+
+ /// <summary>
+ /// Writes the given five-byte tag directly to the stream.
+ /// </summary>
+ public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
+ {
+ WriteRawByte(b1);
+ WriteRawByte(b2);
+ WriteRawByte(b3);
+ WriteRawByte(b4);
+ WriteRawByte(b5);
+ }
+ #endregion
+
#region Write packed array members
// TODO(jonskeet): A lot of these are really inefficient, due to method group conversions. Fix!
- public void WritePackedBoolArray(int fieldNumber, RepeatedField<bool> list)
+ // (Alternatively, add extension methods to RepeatedField, accepting the Write* methods via delegates too.)
+ public void WritePackedBoolArray(RepeatedField<bool> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint)list.Count;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteBoolNoTag(value);
+ WriteBool(value);
}
}
- public void WritePackedInt32Array(int fieldNumber, RepeatedField<int> list)
+ public void WritePackedInt32Array(RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
- uint size = list.CalculateSize(ComputeInt32SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeInt32Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteInt32NoTag(value);
+ WriteInt32(value);
}
}
- public void WritePackedSInt32Array(int fieldNumber, RepeatedField<int> list)
+ public void WritePackedSInt32Array(RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
- uint size = list.CalculateSize(ComputeSInt32SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeSInt32Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSInt32NoTag(value);
+ WriteSInt32(value);
}
}
- public void WritePackedUInt32Array(int fieldNumber, RepeatedField<uint> list)
+ public void WritePackedUInt32Array(RepeatedField<uint> list)
{
- if (list.Count == 0)
- {
- return;
- }
- uint size = list.CalculateSize(ComputeUInt32SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeUInt32Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteUInt32NoTag(value);
+ WriteUInt32(value);
}
}
- public void WritePackedFixed32Array(int fieldNumber, RepeatedField<uint> list)
+ public void WritePackedFixed32Array(RepeatedField<uint> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint) list.Count * 4;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFixed32NoTag(value);
+ WriteFixed32(value);
}
}
- public void WritePackedSFixed32Array(int fieldNumber, RepeatedField<int> list)
+ public void WritePackedSFixed32Array(RepeatedField<int> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint) list.Count * 4;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSFixed32NoTag(value);
+ WriteSFixed32(value);
}
}
- public void WritePackedInt64Array(int fieldNumber, RepeatedField<long> list)
+ public void WritePackedInt64Array(RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
- uint size = list.CalculateSize(ComputeInt64SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeInt64Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteInt64NoTag(value);
+ WriteInt64(value);
}
}
- public void WritePackedSInt64Array(int fieldNumber, RepeatedField<long> list)
+ public void WritePackedSInt64Array(RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
- uint size = list.CalculateSize(ComputeSInt64SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeSInt64Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSInt64NoTag(value);
+ WriteSInt64(value);
}
}
- public void WritePackedUInt64Array(int fieldNumber, RepeatedField<ulong> list)
+ public void WritePackedUInt64Array(RepeatedField<ulong> list)
{
if (list.Count == 0)
{
return;
}
- uint size = list.CalculateSize(ComputeUInt64SizeNoTag);
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
+ uint size = list.CalculateSize(ComputeUInt64Size);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteUInt64NoTag(value);
+ WriteUInt64(value);
}
}
- public void WritePackedFixed64Array(int fieldNumber, RepeatedField<ulong> list)
+ public void WritePackedFixed64Array(RepeatedField<ulong> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint) list.Count * 8;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFixed64NoTag(value);
+ WriteFixed64(value);
}
}
- public void WritePackedSFixed64Array(int fieldNumber, RepeatedField<long> list)
+ public void WritePackedSFixed64Array(RepeatedField<long> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint) list.Count * 8;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteSFixed64NoTag(value);
+ WriteSFixed64(value);
}
}
- public void WritePackedDoubleArray(int fieldNumber, RepeatedField<double> list)
+ public void WritePackedDoubleArray(RepeatedField<double> list)
{
- if (list.Count == 0)
- {
- return;
- }
uint size = (uint) list.Count * 8;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteDoubleNoTag(value);
+ WriteDouble(value);
}
}
- public void WritePackedFloatArray(int fieldNumber, RepeatedField<float> list)
+ public void WritePackedFloatArray(RepeatedField<float> list)
{
if (list.Count == 0)
{
return;
}
uint size = (uint) list.Count * 4;
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
foreach (var value in list)
{
- WriteFloatNoTag(value);
+ WriteFloat(value);
}
}
- public void WritePackedEnumArray<T>(int fieldNumber, RepeatedField<T> list)
+ public void WritePackedEnumArray<T>(RepeatedField<T> list)
where T : struct, IComparable, IFormattable
{
if (list.Count == 0)
@@ -962,29 +681,19 @@ namespace Google.Protobuf
uint size = 0;
while (iterator.MoveNext())
{
- size += (uint) ComputeEnumSizeNoTag(iterator.Current);
+ size += (uint) ComputeEnumSize(iterator.Current);
}
iterator.Reset();
- WriteTag(fieldNumber, WireFormat.WireType.LengthDelimited);
WriteRawVarint32(size);
while (iterator.MoveNext())
{
- WriteEnumNoTag(iterator.Current);
+ WriteEnum(iterator.Current);
}
}
#endregion
#region Underlying writing primitives
-
- /// <summary>
- /// Encodes and writes a tag.
- /// </summary>
- public void WriteTag(int fieldNumber, WireFormat.WireType type)
- {
- WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
- }
-
/// <summary>
/// Writes a 32 bit value as a varint. The fast route is taken when
/// there's enough buffer space left to whizz through without checking
diff --git a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
index 9a10d6ae..44e6e2e9 100644
--- a/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
+++ b/csharp/src/ProtocolBuffers/DescriptorProtos/DescriptorProtoFile.cs
@@ -333,8 +333,9 @@ namespace Google.Protobuf.DescriptorProtos {
int size = 0;
if (file_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.FileDescriptorProto element in file_) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * file_.Count;
}
return size;
}
@@ -508,10 +509,12 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (Package.Length != 0) {
- output.WriteString(2, Package);
+ output.WriteRawTag(18);
+ output.WriteString(Package);
}
if (dependency_.Count > 0) {
output.WriteStringArray(3, dependency_);
@@ -529,10 +532,12 @@ namespace Google.Protobuf.DescriptorProtos {
output.WriteMessageArray(7, extension_);
}
if (options_ != null) {
- output.WriteMessage(8, Options);
+ output.WriteRawTag(66);
+ output.WriteMessage(Options);
}
if (sourceCodeInfo_ != null) {
- output.WriteMessage(9, SourceCodeInfo);
+ output.WriteRawTag(74);
+ output.WriteMessage(SourceCodeInfo);
}
if (publicDependency_.Count > 0) {
output.WriteInt32Array(10, publicDependency_);
@@ -541,22 +546,23 @@ namespace Google.Protobuf.DescriptorProtos {
output.WriteInt32Array(11, weakDependency_);
}
if (Syntax.Length != 0) {
- output.WriteString(12, Syntax);
+ output.WriteRawTag(98);
+ output.WriteString(Syntax);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Package.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(2, Package);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Package);
}
if (dependency_.Count > 0) {
int dataSize = 0;
foreach (string element in dependency_) {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeStringSize(element);
}
size += dataSize;
size += 1 * dependency_.Count;
@@ -564,7 +570,7 @@ namespace Google.Protobuf.DescriptorProtos {
if (publicDependency_.Count > 0) {
int dataSize = 0;
foreach (int element in publicDependency_) {
- dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeInt32Size(element);
}
size += dataSize;
size += 1 * publicDependency_.Count;
@@ -572,39 +578,43 @@ namespace Google.Protobuf.DescriptorProtos {
if (weakDependency_.Count > 0) {
int dataSize = 0;
foreach (int element in weakDependency_) {
- dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeInt32Size(element);
}
size += dataSize;
size += 1 * weakDependency_.Count;
}
if (messageType_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in messageType_) {
- size += pb::CodedOutputStream.ComputeMessageSize(4, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * messageType_.Count;
}
if (enumType_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) {
- size += pb::CodedOutputStream.ComputeMessageSize(5, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * enumType_.Count;
}
if (service_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.ServiceDescriptorProto element in service_) {
- size += pb::CodedOutputStream.ComputeMessageSize(6, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * service_.Count;
}
if (extension_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) {
- size += pb::CodedOutputStream.ComputeMessageSize(7, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * extension_.Count;
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(8, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
if (sourceCodeInfo_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(9, SourceCodeInfo);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceCodeInfo);
}
if (Syntax.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(12, Syntax);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Syntax);
}
return size;
}
@@ -837,7 +847,8 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (field_.Count > 0) {
output.WriteMessageArray(2, field_);
@@ -855,7 +866,8 @@ namespace Google.Protobuf.DescriptorProtos {
output.WriteMessageArray(6, extension_);
}
if (options_ != null) {
- output.WriteMessage(7, Options);
+ output.WriteRawTag(58);
+ output.WriteMessage(Options);
}
if (oneofDecl_.Count > 0) {
output.WriteMessageArray(8, oneofDecl_);
@@ -871,50 +883,57 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (field_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in field_) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * field_.Count;
}
if (extension_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto element in extension_) {
- size += pb::CodedOutputStream.ComputeMessageSize(6, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * extension_.Count;
}
if (nestedType_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto element in nestedType_) {
- size += pb::CodedOutputStream.ComputeMessageSize(3, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * nestedType_.Count;
}
if (enumType_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.EnumDescriptorProto element in enumType_) {
- size += pb::CodedOutputStream.ComputeMessageSize(4, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * enumType_.Count;
}
if (extensionRange_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ExtensionRange element in extensionRange_) {
- size += pb::CodedOutputStream.ComputeMessageSize(5, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * extensionRange_.Count;
}
if (oneofDecl_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.OneofDescriptorProto element in oneofDecl_) {
- size += pb::CodedOutputStream.ComputeMessageSize(8, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * oneofDecl_.Count;
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(7, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
if (reservedRange_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.DescriptorProto.Types.ReservedRange element in reservedRange_) {
- size += pb::CodedOutputStream.ComputeMessageSize(9, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * reservedRange_.Count;
}
if (reservedName_.Count > 0) {
int dataSize = 0;
foreach (string element in reservedName_) {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeStringSize(element);
}
size += dataSize;
size += 1 * reservedName_.Count;
@@ -1065,20 +1084,22 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Start != 0) {
- output.WriteInt32(1, Start);
+ output.WriteRawTag(8);
+ output.WriteInt32(Start);
}
if (End != 0) {
- output.WriteInt32(2, End);
+ output.WriteRawTag(16);
+ output.WriteInt32(End);
}
}
public int CalculateSize() {
int size = 0;
if (Start != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, Start);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start);
}
if (End != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, End);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(End);
}
return size;
}
@@ -1179,20 +1200,22 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Start != 0) {
- output.WriteInt32(1, Start);
+ output.WriteRawTag(8);
+ output.WriteInt32(Start);
}
if (End != 0) {
- output.WriteInt32(2, End);
+ output.WriteRawTag(16);
+ output.WriteInt32(End);
}
}
public int CalculateSize() {
int size = 0;
if (Start != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, Start);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Start);
}
if (End != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, End);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(End);
}
return size;
}
@@ -1366,62 +1389,71 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (Extendee.Length != 0) {
- output.WriteString(2, Extendee);
+ output.WriteRawTag(18);
+ output.WriteString(Extendee);
}
if (Number != 0) {
- output.WriteInt32(3, Number);
+ output.WriteRawTag(24);
+ output.WriteInt32(Number);
}
if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
- output.WriteEnum(4, (int) Label);
+ output.WriteRawTag(32);
+ output.WriteEnum((int) Label);
}
if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
- output.WriteEnum(5, (int) Type);
+ output.WriteRawTag(40);
+ output.WriteEnum((int) Type);
}
if (TypeName.Length != 0) {
- output.WriteString(6, TypeName);
+ output.WriteRawTag(50);
+ output.WriteString(TypeName);
}
if (DefaultValue.Length != 0) {
- output.WriteString(7, DefaultValue);
+ output.WriteRawTag(58);
+ output.WriteString(DefaultValue);
}
if (options_ != null) {
- output.WriteMessage(8, Options);
+ output.WriteRawTag(66);
+ output.WriteMessage(Options);
}
if (OneofIndex != 0) {
- output.WriteInt32(9, OneofIndex);
+ output.WriteRawTag(72);
+ output.WriteInt32(OneofIndex);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Number != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(3, Number);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number);
}
if (Label != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
- size += pb::CodedOutputStream.ComputeEnumSize(4, (int) Label);
+ size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label);
}
if (Type != global::Google.Protobuf.DescriptorProtos.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
- size += pb::CodedOutputStream.ComputeEnumSize(5, (int) Type);
+ size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
}
if (TypeName.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(6, TypeName);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName);
}
if (Extendee.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(2, Extendee);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Extendee);
}
if (DefaultValue.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(7, DefaultValue);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(DefaultValue);
}
if (OneofIndex != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(9, OneofIndex);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(OneofIndex);
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(8, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
return size;
}
@@ -1600,14 +1632,15 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
return size;
}
@@ -1707,28 +1740,31 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (value_.Count > 0) {
output.WriteMessageArray(2, value_);
}
if (options_ != null) {
- output.WriteMessage(3, Options);
+ output.WriteRawTag(26);
+ output.WriteMessage(Options);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (value_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.EnumValueDescriptorProto element in value_) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * value_.Count;
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(3, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
return size;
}
@@ -1848,26 +1884,29 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (Number != 0) {
- output.WriteInt32(2, Number);
+ output.WriteRawTag(16);
+ output.WriteInt32(Number);
}
if (options_ != null) {
- output.WriteMessage(3, Options);
+ output.WriteRawTag(26);
+ output.WriteMessage(Options);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Number != 0) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, Number);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number);
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(3, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
return size;
}
@@ -1987,28 +2026,31 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (method_.Count > 0) {
output.WriteMessageArray(2, method_);
}
if (options_ != null) {
- output.WriteMessage(3, Options);
+ output.WriteRawTag(26);
+ output.WriteMessage(Options);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (method_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.MethodDescriptorProto element in method_) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * method_.Count;
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(3, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
return size;
}
@@ -2158,44 +2200,50 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) {
- output.WriteString(1, Name);
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
if (InputType.Length != 0) {
- output.WriteString(2, InputType);
+ output.WriteRawTag(18);
+ output.WriteString(InputType);
}
if (OutputType.Length != 0) {
- output.WriteString(3, OutputType);
+ output.WriteRawTag(26);
+ output.WriteString(OutputType);
}
if (options_ != null) {
- output.WriteMessage(4, Options);
+ output.WriteRawTag(34);
+ output.WriteMessage(Options);
}
if (ClientStreaming != false) {
- output.WriteBool(5, ClientStreaming);
+ output.WriteRawTag(40);
+ output.WriteBool(ClientStreaming);
}
if (ServerStreaming != false) {
- output.WriteBool(6, ServerStreaming);
+ output.WriteRawTag(48);
+ output.WriteBool(ServerStreaming);
}
}
public int CalculateSize() {
int size = 0;
if (Name.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (InputType.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(2, InputType);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(InputType);
}
if (OutputType.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(3, OutputType);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(OutputType);
}
if (options_ != null) {
- size += pb::CodedOutputStream.ComputeMessageSize(4, Options);
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Options);
}
if (ClientStreaming != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(5, ClientStreaming);
+ size += 1 + 1;
}
if (ServerStreaming != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(6, ServerStreaming);
+ size += 1 + 1;
}
return size;
}
@@ -2458,46 +2506,60 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (JavaPackage.Length != 0) {
- output.WriteString(1, JavaPackage);
+ output.WriteRawTag(10);
+ output.WriteString(JavaPackage);
}
if (JavaOuterClassname.Length != 0) {
- output.WriteString(8, JavaOuterClassname);
+ output.WriteRawTag(66);
+ output.WriteString(JavaOuterClassname);
}
if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) {
- output.WriteEnum(9, (int) OptimizeFor);
+ output.WriteRawTag(72);
+ output.WriteEnum((int) OptimizeFor);
}
if (JavaMultipleFiles != false) {
- output.WriteBool(10, JavaMultipleFiles);
+ output.WriteRawTag(80);
+ output.WriteBool(JavaMultipleFiles);
}
if (GoPackage.Length != 0) {
- output.WriteString(11, GoPackage);
+ output.WriteRawTag(90);
+ output.WriteString(GoPackage);
}
if (CcGenericServices != false) {
- output.WriteBool(16, CcGenericServices);
+ output.WriteRawTag(128, 1);
+ output.WriteBool(CcGenericServices);
}
if (JavaGenericServices != false) {
- output.WriteBool(17, JavaGenericServices);
+ output.WriteRawTag(136, 1);
+ output.WriteBool(JavaGenericServices);
}
if (PyGenericServices != false) {
- output.WriteBool(18, PyGenericServices);
+ output.WriteRawTag(144, 1);
+ output.WriteBool(PyGenericServices);
}
if (JavaGenerateEqualsAndHash != false) {
- output.WriteBool(20, JavaGenerateEqualsAndHash);
+ output.WriteRawTag(160, 1);
+ output.WriteBool(JavaGenerateEqualsAndHash);
}
if (Deprecated != false) {
- output.WriteBool(23, Deprecated);
+ output.WriteRawTag(184, 1);
+ output.WriteBool(Deprecated);
}
if (JavaStringCheckUtf8 != false) {
- output.WriteBool(27, JavaStringCheckUtf8);
+ output.WriteRawTag(216, 1);
+ output.WriteBool(JavaStringCheckUtf8);
}
if (CcEnableArenas != false) {
- output.WriteBool(31, CcEnableArenas);
+ output.WriteRawTag(248, 1);
+ output.WriteBool(CcEnableArenas);
}
if (ObjcClassPrefix.Length != 0) {
- output.WriteString(36, ObjcClassPrefix);
+ output.WriteRawTag(162, 2);
+ output.WriteString(ObjcClassPrefix);
}
if (CsharpNamespace.Length != 0) {
- output.WriteString(37, CsharpNamespace);
+ output.WriteRawTag(170, 2);
+ output.WriteString(CsharpNamespace);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -2507,51 +2569,52 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (JavaPackage.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, JavaPackage);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaPackage);
}
if (JavaOuterClassname.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(8, JavaOuterClassname);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(JavaOuterClassname);
}
if (JavaMultipleFiles != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(10, JavaMultipleFiles);
+ size += 1 + 1;
}
if (JavaGenerateEqualsAndHash != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(20, JavaGenerateEqualsAndHash);
+ size += 2 + 1;
}
if (JavaStringCheckUtf8 != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(27, JavaStringCheckUtf8);
+ size += 2 + 1;
}
if (OptimizeFor != global::Google.Protobuf.DescriptorProtos.FileOptions.Types.OptimizeMode.SPEED) {
- size += pb::CodedOutputStream.ComputeEnumSize(9, (int) OptimizeFor);
+ size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor);
}
if (GoPackage.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(11, GoPackage);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(GoPackage);
}
if (CcGenericServices != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(16, CcGenericServices);
+ size += 2 + 1;
}
if (JavaGenericServices != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(17, JavaGenericServices);
+ size += 2 + 1;
}
if (PyGenericServices != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(18, PyGenericServices);
+ size += 2 + 1;
}
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(23, Deprecated);
+ size += 2 + 1;
}
if (CcEnableArenas != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(31, CcEnableArenas);
+ size += 2 + 1;
}
if (ObjcClassPrefix.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(36, ObjcClassPrefix);
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(ObjcClassPrefix);
}
if (CsharpNamespace.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(37, CsharpNamespace);
+ size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace);
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -2781,16 +2844,20 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (MessageSetWireFormat != false) {
- output.WriteBool(1, MessageSetWireFormat);
+ output.WriteRawTag(8);
+ output.WriteBool(MessageSetWireFormat);
}
if (NoStandardDescriptorAccessor != false) {
- output.WriteBool(2, NoStandardDescriptorAccessor);
+ output.WriteRawTag(16);
+ output.WriteBool(NoStandardDescriptorAccessor);
}
if (Deprecated != false) {
- output.WriteBool(3, Deprecated);
+ output.WriteRawTag(24);
+ output.WriteBool(Deprecated);
}
if (MapEntry != false) {
- output.WriteBool(7, MapEntry);
+ output.WriteRawTag(56);
+ output.WriteBool(MapEntry);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -2800,21 +2867,22 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (MessageSetWireFormat != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(1, MessageSetWireFormat);
+ size += 1 + 1;
}
if (NoStandardDescriptorAccessor != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(2, NoStandardDescriptorAccessor);
+ size += 1 + 1;
}
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated);
+ size += 1 + 1;
}
if (MapEntry != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(7, MapEntry);
+ size += 1 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -2982,22 +3050,28 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) {
- output.WriteEnum(1, (int) Ctype);
+ output.WriteRawTag(8);
+ output.WriteEnum((int) Ctype);
}
if (Packed != false) {
- output.WriteBool(2, Packed);
+ output.WriteRawTag(16);
+ output.WriteBool(Packed);
}
if (Deprecated != false) {
- output.WriteBool(3, Deprecated);
+ output.WriteRawTag(24);
+ output.WriteBool(Deprecated);
}
if (Lazy != false) {
- output.WriteBool(5, Lazy);
+ output.WriteRawTag(40);
+ output.WriteBool(Lazy);
}
if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) {
- output.WriteEnum(6, (int) Jstype);
+ output.WriteRawTag(48);
+ output.WriteEnum((int) Jstype);
}
if (Weak != false) {
- output.WriteBool(10, Weak);
+ output.WriteRawTag(80);
+ output.WriteBool(Weak);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -3007,27 +3081,28 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (Ctype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.CType.STRING) {
- size += pb::CodedOutputStream.ComputeEnumSize(1, (int) Ctype);
+ size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype);
}
if (Packed != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(2, Packed);
+ size += 1 + 1;
}
if (Jstype != global::Google.Protobuf.DescriptorProtos.FieldOptions.Types.JSType.JS_NORMAL) {
- size += pb::CodedOutputStream.ComputeEnumSize(6, (int) Jstype);
+ size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype);
}
if (Lazy != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(5, Lazy);
+ size += 1 + 1;
}
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated);
+ size += 1 + 1;
}
if (Weak != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(10, Weak);
+ size += 1 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -3187,10 +3262,12 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (AllowAlias != false) {
- output.WriteBool(2, AllowAlias);
+ output.WriteRawTag(16);
+ output.WriteBool(AllowAlias);
}
if (Deprecated != false) {
- output.WriteBool(3, Deprecated);
+ output.WriteRawTag(24);
+ output.WriteBool(Deprecated);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -3200,15 +3277,16 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (AllowAlias != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(2, AllowAlias);
+ size += 1 + 1;
}
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(3, Deprecated);
+ size += 1 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -3312,7 +3390,8 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(1, Deprecated);
+ output.WriteRawTag(8);
+ output.WriteBool(Deprecated);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -3322,12 +3401,13 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(1, Deprecated);
+ size += 1 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -3424,7 +3504,8 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(33, Deprecated);
+ output.WriteRawTag(136, 2);
+ output.WriteBool(Deprecated);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -3434,12 +3515,13 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated);
+ size += 2 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -3536,7 +3618,8 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (Deprecated != false) {
- output.WriteBool(33, Deprecated);
+ output.WriteRawTag(136, 2);
+ output.WriteBool(Deprecated);
}
if (uninterpretedOption_.Count > 0) {
output.WriteMessageArray(999, uninterpretedOption_);
@@ -3546,12 +3629,13 @@ namespace Google.Protobuf.DescriptorProtos {
public int CalculateSize() {
int size = 0;
if (Deprecated != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(33, Deprecated);
+ size += 2 + 1;
}
if (uninterpretedOption_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption element in uninterpretedOption_) {
- size += pb::CodedOutputStream.ComputeMessageSize(999, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 2 * uninterpretedOption_.Count;
}
return size;
}
@@ -3701,22 +3785,28 @@ namespace Google.Protobuf.DescriptorProtos {
output.WriteMessageArray(2, name_);
}
if (IdentifierValue.Length != 0) {
- output.WriteString(3, IdentifierValue);
+ output.WriteRawTag(26);
+ output.WriteString(IdentifierValue);
}
if (PositiveIntValue != 0UL) {
- output.WriteUInt64(4, PositiveIntValue);
+ output.WriteRawTag(32);
+ output.WriteUInt64(PositiveIntValue);
}
if (NegativeIntValue != 0L) {
- output.WriteInt64(5, NegativeIntValue);
+ output.WriteRawTag(40);
+ output.WriteInt64(NegativeIntValue);
}
if (DoubleValue != 0D) {
- output.WriteDouble(6, DoubleValue);
+ output.WriteRawTag(49);
+ output.WriteDouble(DoubleValue);
}
if (StringValue.Length != 0) {
- output.WriteBytes(7, StringValue);
+ output.WriteRawTag(58);
+ output.WriteBytes(StringValue);
}
if (AggregateValue.Length != 0) {
- output.WriteString(8, AggregateValue);
+ output.WriteRawTag(66);
+ output.WriteString(AggregateValue);
}
}
@@ -3724,26 +3814,27 @@ namespace Google.Protobuf.DescriptorProtos {
int size = 0;
if (name_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.UninterpretedOption.Types.NamePart element in name_) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * name_.Count;
}
if (IdentifierValue.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(3, IdentifierValue);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(IdentifierValue);
}
if (PositiveIntValue != 0UL) {
- size += pb::CodedOutputStream.ComputeUInt64Size(4, PositiveIntValue);
+ size += 1 + pb::CodedOutputStream.ComputeUInt64Size(PositiveIntValue);
}
if (NegativeIntValue != 0L) {
- size += pb::CodedOutputStream.ComputeInt64Size(5, NegativeIntValue);
+ size += 1 + pb::CodedOutputStream.ComputeInt64Size(NegativeIntValue);
}
if (DoubleValue != 0D) {
- size += pb::CodedOutputStream.ComputeDoubleSize(6, DoubleValue);
+ size += 1 + 8;
}
if (StringValue.Length != 0) {
- size += pb::CodedOutputStream.ComputeBytesSize(7, StringValue);
+ size += 1 + pb::CodedOutputStream.ComputeBytesSize(StringValue);
}
if (AggregateValue.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(8, AggregateValue);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(AggregateValue);
}
return size;
}
@@ -3878,20 +3969,22 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (NamePart_.Length != 0) {
- output.WriteString(1, NamePart_);
+ output.WriteRawTag(10);
+ output.WriteString(NamePart_);
}
if (IsExtension != false) {
- output.WriteBool(2, IsExtension);
+ output.WriteRawTag(16);
+ output.WriteBool(IsExtension);
}
}
public int CalculateSize() {
int size = 0;
if (NamePart_.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(1, NamePart_);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(NamePart_);
}
if (IsExtension != false) {
- size += pb::CodedOutputStream.ComputeBoolSize(2, IsExtension);
+ size += 1 + 1;
}
return size;
}
@@ -3993,8 +4086,9 @@ namespace Google.Protobuf.DescriptorProtos {
int size = 0;
if (location_.Count > 0) {
foreach (global::Google.Protobuf.DescriptorProtos.SourceCodeInfo.Types.Location element in location_) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, element);
+ size += pb::CodedOutputStream.ComputeMessageSize(element);
}
+ size += 1 * location_.Count;
}
return size;
}
@@ -4111,16 +4205,20 @@ namespace Google.Protobuf.DescriptorProtos {
public void WriteTo(pb::CodedOutputStream output) {
if (path_.Count > 0) {
- output.WritePackedInt32Array(1, path_);
+ output.WriteRawTag(10);
+ output.WritePackedInt32Array(path_);
}
if (span_.Count > 0) {
- output.WritePackedInt32Array(2, span_);
+ output.WriteRawTag(18);
+ output.WritePackedInt32Array(span_);
}
if (LeadingComments.Length != 0) {
- output.WriteString(3, LeadingComments);
+ output.WriteRawTag(26);
+ output.WriteString(LeadingComments);
}
if (TrailingComments.Length != 0) {
- output.WriteString(4, TrailingComments);
+ output.WriteRawTag(34);
+ output.WriteString(TrailingComments);
}
if (leadingDetachedComments_.Count > 0) {
output.WriteStringArray(6, leadingDetachedComments_);
@@ -4132,29 +4230,29 @@ namespace Google.Protobuf.DescriptorProtos {
if (path_.Count > 0) {
int dataSize = 0;
foreach (int element in path_) {
- dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeInt32Size(element);
}
size += dataSize;
- size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize);
}
if (span_.Count > 0) {
int dataSize = 0;
foreach (int element in span_) {
- dataSize += pb::CodedOutputStream.ComputeInt32SizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeInt32Size(element);
}
size += dataSize;
- size += 1 + pb::CodedOutputStream.ComputeInt32SizeNoTag(dataSize);
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(dataSize);
}
if (LeadingComments.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(3, LeadingComments);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(LeadingComments);
}
if (TrailingComments.Length != 0) {
- size += pb::CodedOutputStream.ComputeStringSize(4, TrailingComments);
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(TrailingComments);
}
if (leadingDetachedComments_.Count > 0) {
int dataSize = 0;
foreach (string element in leadingDetachedComments_) {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
+ dataSize += pb::CodedOutputStream.ComputeStringSize(element);
}
size += dataSize;
size += 1 * leadingDetachedComments_.Count;