fix(core): Fixes SpanReader moving position before read (#468)

This commit is contained in:
Jabin 2021-02-06 18:45:44 +11:00 committed by GitHub
parent 67625ad249
commit 52df92c452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -164,8 +164,9 @@ namespace System.Buffers
int index = _buffer.Slice(Position, size).IndexOfTerminator(sizeT);
var span = _buffer.Slice(Position, index < 0 ? size : index);
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)]