Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ static virtual TSelf Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFor
scoped Span<char> utf16Text;
int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);

if (textMaxCharCount < 256)
if (textMaxCharCount <= 256)
{
utf16TextArray = null;
utf16Text = stackalloc char[256];
}
else
{
utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount);
utf16Text = utf16TextArray.AsSpan(0, textMaxCharCount);
utf16Text = utf16TextArray;
}

OperationStatus utf8TextStatus = Utf8.ToUtf16(utf8Text, utf16Text, out _, out int utf16TextLength, replaceInvalidSequences: false);
Expand Down Expand Up @@ -440,15 +440,15 @@ static virtual bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IF
scoped Span<char> utf16Text;
int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);

if (textMaxCharCount < 256)
if (textMaxCharCount <= 256)
{
utf16TextArray = null;
utf16Text = stackalloc char[256];
}
else
{
utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount);
utf16Text = utf16TextArray.AsSpan(0, textMaxCharCount);
utf16Text = utf16TextArray;
}

OperationStatus utf8TextStatus = Utf8.ToUtf16(utf8Text, utf16Text, out _, out int utf16TextLength, replaceInvalidSequences: false);
Expand Down Expand Up @@ -486,15 +486,15 @@ bool IUtf8SpanFormattable.TryFormat(Span<byte> utf8Destination, out int bytesWri
scoped Span<char> utf16Destination;
int destinationMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Destination.Length);

if (destinationMaxCharCount < 256)
if (destinationMaxCharCount <= 256)
{
utf16DestinationArray = null;
utf16Destination = stackalloc char[256];
}
else
{
utf16DestinationArray = ArrayPool<char>.Shared.Rent(destinationMaxCharCount);
utf16Destination = utf16DestinationArray.AsSpan(0, destinationMaxCharCount);
utf16Destination = utf16DestinationArray;
}

if (!TryFormat(utf16Destination, out int charsWritten, format, provider))
Expand Down Expand Up @@ -542,15 +542,15 @@ static TSelf IUtf8SpanParsable<TSelf>.Parse(ReadOnlySpan<byte> utf8Text, IFormat
scoped Span<char> utf16Text;
int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);

if (textMaxCharCount < 256)
if (textMaxCharCount <= 256)
{
utf16TextArray = null;
utf16Text = stackalloc char[256];
}
else
{
utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount);
utf16Text = utf16TextArray.AsSpan(0, textMaxCharCount);
utf16Text = utf16TextArray;
}

OperationStatus utf8TextStatus = Utf8.ToUtf16(utf8Text, utf16Text, out _, out int utf16TextLength, replaceInvalidSequences: false);
Expand Down Expand Up @@ -589,15 +589,15 @@ static bool IUtf8SpanParsable<TSelf>.TryParse(ReadOnlySpan<byte> utf8Text, IForm
scoped Span<char> utf16Text;
int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);

if (textMaxCharCount < 256)
if (textMaxCharCount <= 256)
{
utf16TextArray = null;
utf16Text = stackalloc char[256];
}
else
{
utf16TextArray = ArrayPool<char>.Shared.Rent(textMaxCharCount);
utf16Text = utf16TextArray.AsSpan(0, textMaxCharCount);
utf16Text = utf16TextArray;
}

OperationStatus utf8TextStatus = Utf8.ToUtf16(utf8Text, utf16Text, out _, out int utf16TextLength, replaceInvalidSequences: false);
Expand Down