aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Collections/MapField.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-06-26 17:37:14 +0100
committerJon Skeet <jonskeet@google.com>2015-06-30 13:20:30 +0100
commitf2a27cc2c71b4dae3ff230574a73c1de88dd61b7 (patch)
tree58cdbbbd9262732c9a104171f2563f0f2da85acb /csharp/src/ProtocolBuffers/Collections/MapField.cs
parent241e17ba78b71a7ecccb289914ecaeab203b2373 (diff)
downloadprotobuf-f2a27cc2c71b4dae3ff230574a73c1de88dd61b7.tar.gz
protobuf-f2a27cc2c71b4dae3ff230574a73c1de88dd61b7.tar.bz2
protobuf-f2a27cc2c71b4dae3ff230574a73c1de88dd61b7.zip
First pass (not yet compiling) at removing all the array handling code from Coded*Stream.
Prod code works, but some tests are broken. Obviously those need fixing, then more tests, and review benchmarks.
Diffstat (limited to 'csharp/src/ProtocolBuffers/Collections/MapField.cs')
-rw-r--r--csharp/src/ProtocolBuffers/Collections/MapField.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/csharp/src/ProtocolBuffers/Collections/MapField.cs b/csharp/src/ProtocolBuffers/Collections/MapField.cs
index 9eed833f..6d1097a6 100644
--- a/csharp/src/ProtocolBuffers/Collections/MapField.cs
+++ b/csharp/src/ProtocolBuffers/Collections/MapField.cs
@@ -334,6 +334,10 @@ namespace Google.Protobuf.Collections
public int CalculateSize(Codec codec)
{
+ if (Count == 0)
+ {
+ return 0;
+ }
var message = new Codec.MessageAdapter(codec);
int size = 0;
foreach (var entry in list)
@@ -419,13 +423,13 @@ namespace Google.Protobuf.Collections
public void WriteTo(CodedOutputStream output)
{
- codec.keyCodec.Write(output, Key);
- codec.valueCodec.Write(output, Value);
+ codec.keyCodec.WriteTagAndValue(output, Key);
+ codec.valueCodec.WriteTagAndValue(output, Value);
}
public int CalculateSize()
{
- return codec.keyCodec.CalculateSize(Key) + codec.valueCodec.CalculateSize(Value);
+ return codec.keyCodec.CalculateSizeWithTag(Key) + codec.valueCodec.CalculateSizeWithTag(Value);
}
}
}