Commit 5685e987 authored by Jon Skeet's avatar Jon Skeet

Simplify ComputeInt32Size to call ComputeInt32SizeNoTag.

parent 1b71db11
...@@ -91,15 +91,7 @@ namespace Google.Protobuf ...@@ -91,15 +91,7 @@ namespace Google.Protobuf
/// </summary> /// </summary>
public static int ComputeInt32Size(int fieldNumber, int value) public static int ComputeInt32Size(int fieldNumber, int value)
{ {
if (value >= 0) return ComputeTagSize(fieldNumber) + ComputeInt32SizeNoTag(value);
{
return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) value);
}
else
{
// Must sign-extend.
return ComputeTagSize(fieldNumber) + 10;
}
} }
/// <summary> /// <summary>
...@@ -418,7 +410,6 @@ namespace Google.Protobuf ...@@ -418,7 +410,6 @@ namespace Google.Protobuf
/// </summary> /// </summary>
public static int ComputeRawVarint32Size(uint value) public static int ComputeRawVarint32Size(uint value)
{ {
// TODO(jonskeet): Look at optimizing this to just hard-coded comparisons.
if ((value & (0xffffffff << 7)) == 0) if ((value & (0xffffffff << 7)) == 0)
{ {
return 1; return 1;
...@@ -443,7 +434,6 @@ namespace Google.Protobuf ...@@ -443,7 +434,6 @@ namespace Google.Protobuf
/// </summary> /// </summary>
public static int ComputeRawVarint64Size(ulong value) public static int ComputeRawVarint64Size(ulong value)
{ {
// TODO(jonskeet): Look at optimizing this to just hard-coded comparisons.
if ((value & (0xffffffffffffffffL << 7)) == 0) if ((value & (0xffffffffffffffffL << 7)) == 0)
{ {
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment