Update src/SharpCompress/IO/ReadOnlySubStream.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Adam Hathcock
2026-01-06 16:33:03 +00:00
committed by GitHub
parent 833dd7b3a2
commit fd968b3f78

View File

@@ -124,12 +124,9 @@ internal class ReadOnlySubStream : SharpCompressStream, IStreamStack
)
{
var sliceLen = BytesLeftToRead < buffer.Length ? BytesLeftToRead : buffer.Length;
var mem = buffer;
if (sliceLen != buffer.Length)
{
mem = buffer.Slice(0, (int)sliceLen);
}
var read = await Stream.ReadAsync(mem, cancellationToken).ConfigureAwait(false);
var read = await Stream
.ReadAsync(buffer.Slice(0, (int)sliceLen), cancellationToken)
.ConfigureAwait(false);
if (read > 0)
{
BytesLeftToRead -= read;