internal bool ReadLine (out byte[] buffer, out int offset, out int count, CancellationToken cancellationToken)
{
CheckDisposed ();
unsafe {
fixed (byte* inbuf = input) {
byte* start, inptr, inend;
// we need at least 1 byte: "\n"
ReadAhead (1, cancellationToken);
offset = inputIndex;
buffer = input;
start = inbuf + inputIndex;
inend = inbuf + inputEnd;
*inend = (byte) '\n';
inptr = start;
// FIXME: use SIMD to optimize this
while (*inptr != (byte) '\n')
inptr++;
inputIndex = (int) (inptr - inbuf);
count = (int) (inptr - start);
if (inptr == inend)
return false;
// consume the '\n'
inputIndex++;
count++;
return true;
}
}
}