Skip to content

Commit 7eda30c

Browse files
committed
Add comments
1 parent 8f6304a commit 7eda30c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

csharp/src/Google.Protobuf/Collections/RepeatedField.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void AddEntriesFrom(ref ParseContext ctx, FieldCodec<T> codec)
119119
EnsureSize(count + (length / codec.FixedSize));
120120

121121

122-
// if little endian try to copy packed buffer into RepeatedField array
122+
// if littleEndian treat array as bytes and directly copy from buffer for improved performance
123123
if(BitConverter.IsLittleEndian)
124124
{
125125
GCHandle handle = AsSpanPinnedUnsafe(out Span<byte> span, codec);
@@ -258,6 +258,7 @@ public void WriteTo(ref WriteContext ctx, FieldCodec<T> codec)
258258
ctx.WriteTag(tag);
259259
ctx.WriteLength(size);
260260

261+
// if littleEndian and elements has fixed size, treat array as bytes (and write it as bytes to buffer) for improved performance
261262
if(BitConverter.IsLittleEndian && codec.FixedSize > 0)
262263
{
263264
GCHandle handle = AsSpanPinnedUnsafe(out Span<byte> span, codec);

0 commit comments

Comments
 (0)