fix: Fixes reading multiple strings (books) (#1814)
This commit is contained in:
parent
5f8f7982eb
commit
aeba2261d2
1 changed files with 3 additions and 2 deletions
|
|
@ -195,11 +195,12 @@ public ref struct SpanReader
|
||||||
|
|
||||||
var span = _buffer.Slice(Position, size);
|
var span = _buffer.Slice(Position, size);
|
||||||
var index = span.IndexOfTerminator(byteLength);
|
var index = span.IndexOfTerminator(byteLength);
|
||||||
|
span = _buffer.Slice(Position, index);
|
||||||
|
|
||||||
Position += isFixedLength || index < 0 ? size : index;
|
Position += isFixedLength || index < 0 ? size : index + 1;
|
||||||
|
|
||||||
// The string is either as long as the first terminator character, remaining buffer size, or fixed length.
|
// The string is either as long as the first terminator character, remaining buffer size, or fixed length.
|
||||||
return TextEncoding.GetString(span[..(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