fix(core): Fixes SpanReader moving position before read (#468)
This commit is contained in:
parent
67625ad249
commit
52df92c452
1 changed files with 2 additions and 1 deletions
|
|
@ -164,8 +164,9 @@ namespace System.Buffers
|
||||||
|
|
||||||
int index = _buffer.Slice(Position, size).IndexOfTerminator(sizeT);
|
int index = _buffer.Slice(Position, size).IndexOfTerminator(sizeT);
|
||||||
|
|
||||||
|
var span = _buffer.Slice(Position, index < 0 ? size : index);
|
||||||
Position += isFixedLength || index < 0 ? size : index + sizeT;
|
Position += isFixedLength || index < 0 ? size : index + sizeT;
|
||||||
return TextEncoding.GetString(_buffer.Slice(Position, index < 0 ? size : index), encoding, safeString);
|
return TextEncoding.GetString(span, encoding, safeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue