Skip to content

Commit

Permalink
Comment
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jan 28, 2021
1 parent d4df924 commit 93fafb0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion csharp/src/Google.Protobuf/WritingPrimitives.cs
Expand Up @@ -202,7 +202,8 @@ public static void WriteString(ref Span<byte> buffer, ref WriterInternalState st
? WriteAsciiStringToBuffer(ref sourceChars, ref destinationBytes, value, length)
: 0;

// This avoids bound checks
// Process any remaining, 1 char at a time.
// Avoid bounds checking with ref + Unsafe
for (; currentIndex < length; currentIndex++)
{
Unsafe.AddByteOffset(ref destinationBytes, (IntPtr)currentIndex) = (byte)Unsafe.AddByteOffset(ref sourceChars, (IntPtr)(currentIndex * 2));
Expand Down

0 comments on commit 93fafb0

Please sign in to comment.