Browse Source

optimize WriteString

Jan Tattermusch 5 years ago
parent
commit
17a4b181a0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      csharp/src/Google.Protobuf/WritingPrimitives.cs

+ 1 - 1
csharp/src/Google.Protobuf/WritingPrimitives.cs

@@ -167,7 +167,7 @@ namespace Google.Protobuf
             // the string directly to the buffer, which should be common.
             // the string directly to the buffer, which should be common.
             int length = Utf8Encoding.GetByteCount(value);
             int length = Utf8Encoding.GetByteCount(value);
             WriteLength(ref buffer, ref state, length);
             WriteLength(ref buffer, ref state, length);
-            if (state.limit - state.position >= length)
+            if (buffer.Length - state.position >= length)
             {
             {
                 if (length == value.Length) // Must be all ASCII...
                 if (length == value.Length) // Must be all ASCII...
                 {
                 {