optimize WriteRawByte
diff --git a/csharp/src/Google.Protobuf/WriteBufferHelper.cs b/csharp/src/Google.Protobuf/WriteBufferHelper.cs
index f6617c9..f2a59bc 100644
--- a/csharp/src/Google.Protobuf/WriteBufferHelper.cs
+++ b/csharp/src/Google.Protobuf/WriteBufferHelper.cs
@@ -117,7 +117,7 @@
             }
         }
 
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        [MethodImpl(MethodImplOptions.NoInlining)]
         public static void RefreshBuffer(ref Span<byte> buffer, ref WriterInternalState state)
         {
             if (state.writeBufferHelper.codedOutputStream?.InternalOutputStream != null)
diff --git a/csharp/src/Google.Protobuf/WritingPrimitives.cs b/csharp/src/Google.Protobuf/WritingPrimitives.cs
index a4a229d..ed76682 100644
--- a/csharp/src/Google.Protobuf/WritingPrimitives.cs
+++ b/csharp/src/Google.Protobuf/WritingPrimitives.cs
@@ -397,9 +397,9 @@
             WriteRawByte(ref buffer, ref state, (byte)(value >> 56));
         }
 
-        public static void WriteRawByte(ref Span<byte> buffer, ref WriterInternalState state, byte value)
+        private static void WriteRawByte(ref Span<byte> buffer, ref WriterInternalState state, byte value)
         {
-            if (state.position == state.limit)
+            if (state.position == buffer.Length)
             {
                 WriteBufferHelper.RefreshBuffer(ref buffer, ref state);
             }