Skip to content

Commit

Permalink
Do not force flush when ODataUtf8JsonWriter buffer threshold is reach…
Browse files Browse the repository at this point in the history
…ed (#3102)
  • Loading branch information
habbes authored Oct 30, 2024
1 parent b84465b commit 1848964
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 80 deletions.
6 changes: 3 additions & 3 deletions src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task EndStreamValueScopeAsync()
this.binaryValueStream = null;
}

await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false);
await this.DrainBufferIfThresholdReachedAsync().ConfigureAwait(false);

this.bufferWriter.Write(this.DoubleQuote.Slice(0, 1).Span);

Expand Down Expand Up @@ -282,7 +282,7 @@ private void WriteByteValueInChunks(ReadOnlySpan<byte> value)
}

// Flush the writer if the buffer threshold is reached
this.jsonWriter.FlushIfBufferThresholdReached();
this.jsonWriter.DrainBufferIfThresholdReached();
}
}

Expand Down Expand Up @@ -328,7 +328,7 @@ private async ValueTask WriteByteValueInChunksAsync(ReadOnlyMemory<byte> value)
}

// Flush the writer if the buffer threshold is reached
await this.jsonWriter.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false);
await this.jsonWriter.DrainBufferIfThresholdReachedAsync().ConfigureAwait(false);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.OData.Core/Json/ODataUtf8JsonWriter.TextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task EndTextWriterValueScopeAsync()
await this.textWriter.DisposeAsync();
}

await this.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false);
await this.DrainBufferIfThresholdReachedAsync().ConfigureAwait(false);

CheckIfSeparatorNeeded();
CheckIfManualValueAtArrayStart();
Expand Down Expand Up @@ -337,7 +337,7 @@ private void WriteCharsInChunks(ReadOnlySpan<char> value)
}

// Flush the writer if the buffer threshold is reached
this.jsonWriter.FlushIfBufferThresholdReached();
this.jsonWriter.DrainBufferIfThresholdReached();
}
}

Expand Down Expand Up @@ -387,7 +387,7 @@ private async ValueTask WriteCharsInChunksAsync(ReadOnlyMemory<char> value)
}

// Flush the writer if the buffer threshold is reached
await this.jsonWriter.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false);
await this.jsonWriter.DrainBufferIfThresholdReachedAsync().ConfigureAwait(false);
}
}

Expand Down Expand Up @@ -431,7 +431,7 @@ private void WriteCharsInChunksWithoutEscaping(ReadOnlySpan<char> value)
}

// Flush the writer if the buffer threshold is reached
this.jsonWriter.FlushIfBufferThresholdReached();
this.jsonWriter.DrainBufferIfThresholdReached();
}
}

Expand Down Expand Up @@ -475,7 +475,7 @@ private async ValueTask WriteCharsInChunksWithoutEscapingAsync(ReadOnlyMemory<ch
}

// Flush the writer if the buffer threshold is reached
await this.jsonWriter.FlushIfBufferThresholdReachedAsync().ConfigureAwait(false);
await this.jsonWriter.DrainBufferIfThresholdReachedAsync().ConfigureAwait(false);
}
}

Expand Down
Loading

0 comments on commit 1848964

Please sign in to comment.