Remove .Start from BufferSegment (#6832)
This commit is contained in:
parent
447f4bc298
commit
14d8e33a93
|
|
@ -13,13 +13,6 @@ namespace System.IO.Pipelines
|
|||
private BufferSegment _next;
|
||||
private int _end;
|
||||
|
||||
/// <summary>
|
||||
/// The Start represents the offset into AvailableMemory where the range of "active" bytes begins. At the point when the block is leased
|
||||
/// the Start is guaranteed to be equal to 0. The value of Start may be assigned anywhere between 0 and
|
||||
/// AvailableMemory.Length, and must be equal to or less than End.
|
||||
/// </summary>
|
||||
public int Start { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The End represents the offset into AvailableMemory where the range of "active" bytes ends. At the point when the block is leased
|
||||
/// the End is guaranteed to be equal to Start. The value of Start may be assigned anywhere between 0 and
|
||||
|
|
@ -30,10 +23,10 @@ namespace System.IO.Pipelines
|
|||
get => _end;
|
||||
set
|
||||
{
|
||||
Debug.Assert(value - Start <= AvailableMemory.Length);
|
||||
Debug.Assert(value <= AvailableMemory.Length);
|
||||
|
||||
_end = value;
|
||||
Memory = AvailableMemory.Slice(Start, _end - Start);
|
||||
Memory = AvailableMemory.Slice(0, _end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,19 +47,13 @@ namespace System.IO.Pipelines
|
|||
}
|
||||
|
||||
public void SetMemory(IMemoryOwner<byte> memoryOwner)
|
||||
{
|
||||
SetMemory(memoryOwner, 0, 0);
|
||||
}
|
||||
|
||||
public void SetMemory(IMemoryOwner<byte> memoryOwner, int start, int end)
|
||||
{
|
||||
_memoryOwner = memoryOwner;
|
||||
|
||||
AvailableMemory = _memoryOwner.Memory;
|
||||
|
||||
RunningIndex = 0;
|
||||
Start = start;
|
||||
End = end;
|
||||
End = 0;
|
||||
NextSegment = null;
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +68,7 @@ namespace System.IO.Pipelines
|
|||
|
||||
public Memory<byte> AvailableMemory { get; private set; }
|
||||
|
||||
public int Length => End - Start;
|
||||
public int Length => End;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of writable bytes in this segment. It is the amount of bytes between Length and End
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Pipelines;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -136,7 +132,7 @@ namespace System.IO.Pipelines
|
|||
{
|
||||
// If we examined everything, we force ReadAsync to actually read from the underlying stream
|
||||
// instead of returning a ReadResult from TryRead.
|
||||
_examinedEverything = examinedIndex == _readTail.End - _readTail.Start;
|
||||
_examinedEverything = examinedIndex == _readTail.End;
|
||||
}
|
||||
|
||||
// Three cases here:
|
||||
|
|
@ -321,7 +317,7 @@ namespace System.IO.Pipelines
|
|||
|
||||
private ReadOnlySequence<byte> GetCurrentReadOnlySequence()
|
||||
{
|
||||
return new ReadOnlySequence<byte>(_readHead, _readIndex, _readTail, _readTail.End - _readTail.Start);
|
||||
return new ReadOnlySequence<byte>(_readHead, _readIndex, _readTail, _readTail.End);
|
||||
}
|
||||
|
||||
private void AllocateReadTail()
|
||||
|
|
|
|||
Loading…
Reference in New Issue