From f34d37a3d4d64621bc87aa0a65a05cab64062399 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 30 Jun 2015 13:16:20 +0100 Subject: Tidying up and extra tests. This is mostly just making things internal instead of public, removing and reordering a bunch of code in CodedInputStream/CodedOutputStream, and generally tidying up. --- csharp/src/ProtocolBuffers/Collections/RepeatedField.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'csharp/src/ProtocolBuffers/Collections/RepeatedField.cs') diff --git a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs index 588f66a4..0d82e3bc 100644 --- a/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs +++ b/csharp/src/ProtocolBuffers/Collections/RepeatedField.cs @@ -51,12 +51,14 @@ namespace Google.Protobuf.Collections public void AddEntriesFrom(CodedInputStream input, FieldCodec codec) { + // TODO: Inline some of the Add code, so we can avoid checking the size on every + // iteration and the mutability. uint tag = input.LastTag; var reader = codec.ValueReader; // Value types can be packed or not. if (typeof(T).IsValueType && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited) { - int length = (int)(input.ReadRawVarint32() & int.MaxValue); + int length = input.ReadLength(); if (length > 0) { int oldLimit = input.PushLimit(length); @@ -125,7 +127,6 @@ namespace Google.Protobuf.Collections public void WriteTo(CodedOutputStream output, FieldCodec codec) { - // TODO: Assert that T is a value type, and that codec.Tag is packed? if (count == 0) { return; @@ -172,9 +173,9 @@ namespace Google.Protobuf.Collections private void EnsureSize(int size) { - size = Math.Max(size, MinArraySize); if (array.Length < size) { + size = Math.Max(size, MinArraySize); int newSize = Math.Max(array.Length * 2, size); var tmp = new T[newSize]; Array.Copy(array, 0, tmp, 0, array.Length); -- cgit v1.2.3