public void SetWindow(int windowOffset, int windowLength)
{
// [0...elementOffset-1][elementOffset..offset][offset..offsetMax-1][offsetMax..buffer.Length]
// ^--Elements, Attributes in scope
// ^-- The node just consumed
// ^--Data buffered, not consumed
// ^--Unused space
if (windowOffset > int.MaxValue - windowLength)
windowLength = int.MaxValue - windowOffset;
if (_offset != windowOffset)
{
System.Buffer.BlockCopy(_buffer, _offset, _buffer, windowOffset, _offsetMax - _offset);
_offsetMax = windowOffset + (_offsetMax - _offset);
_offset = windowOffset;
}
_windowOffset = windowOffset;
_windowOffsetMax = Math.Max(windowOffset + windowLength, _offsetMax);
}