From 5685e987112077b2df9fc59acfbfa30f1e3ea38b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 12 Jun 2015 11:47:47 +0100 Subject: [PATCH] Simplify ComputeInt32Size to call ComputeInt32SizeNoTag. --- .../ProtocolBuffers/CodedOutputStream.ComputeSize.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs index b7629d7c04..aba5a1a2b5 100644 --- a/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs +++ b/csharp/src/ProtocolBuffers/CodedOutputStream.ComputeSize.cs @@ -91,15 +91,7 @@ namespace Google.Protobuf /// public static int ComputeInt32Size(int fieldNumber, int value) { - if (value >= 0) - { - return ComputeTagSize(fieldNumber) + ComputeRawVarint32Size((uint) value); - } - else - { - // Must sign-extend. - return ComputeTagSize(fieldNumber) + 10; - } + return ComputeTagSize(fieldNumber) + ComputeInt32SizeNoTag(value); } /// @@ -418,7 +410,6 @@ namespace Google.Protobuf /// public static int ComputeRawVarint32Size(uint value) { - // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffff << 7)) == 0) { return 1; @@ -443,7 +434,6 @@ namespace Google.Protobuf /// public static int ComputeRawVarint64Size(ulong value) { - // TODO(jonskeet): Look at optimizing this to just hard-coded comparisons. if ((value & (0xffffffffffffffffL << 7)) == 0) { return 1;