Skip to content

Commit

Permalink
Buffer position
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Feb 2, 2024
1 parent d3c0288 commit 6334b57
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/NATS.Client.Core/Commands/CommandWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,18 @@ private static async Task ReaderLoopAsync(ILogger<CommandWriter> logger, ISocket

var buffer = result.Buffer;
var consumed = buffer.Start;

buffer = buffer.Slice(examinedOffset);
var examined = buffer.Start;
var examined = buffer.GetPosition(examinedOffset);

try
{
if (!buffer.IsEmpty)
{
var bufferLength = (int)buffer.Length;
var readBuffer = buffer.Slice(examinedOffset);
var bufferLength = (int)readBuffer.Length;

var bytes = ArrayPool<byte>.Shared.Rent(bufferLength);
buffer.CopyTo(bytes);
var memory = bytes.AsMemory(0, (int)buffer.Length);
readBuffer.CopyTo(bytes);
var memory = bytes.AsMemory(0, bufferLength);

try
{
Expand Down

0 comments on commit 6334b57

Please sign in to comment.