@@ -306,15 +306,15 @@ static virtual TSelf Parse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IFor
306
306
scoped Span < char > utf16Text ;
307
307
int textMaxCharCount = Encoding . UTF8 . GetMaxCharCount ( utf8Text . Length ) ;
308
308
309
- if ( textMaxCharCount < 256 )
309
+ if ( textMaxCharCount <= 256 )
310
310
{
311
311
utf16TextArray = null ;
312
312
utf16Text = stackalloc char [ 256 ] ;
313
313
}
314
314
else
315
315
{
316
316
utf16TextArray = ArrayPool < char > . Shared . Rent ( textMaxCharCount ) ;
317
- utf16Text = utf16TextArray . AsSpan ( 0 , textMaxCharCount ) ;
317
+ utf16Text = utf16TextArray ;
318
318
}
319
319
320
320
OperationStatus utf8TextStatus = Utf8 . ToUtf16 ( utf8Text , utf16Text , out _ , out int utf16TextLength , replaceInvalidSequences : false ) ;
@@ -440,15 +440,15 @@ static virtual bool TryParse(ReadOnlySpan<byte> utf8Text, NumberStyles style, IF
440
440
scoped Span < char > utf16Text ;
441
441
int textMaxCharCount = Encoding . UTF8 . GetMaxCharCount ( utf8Text . Length ) ;
442
442
443
- if ( textMaxCharCount < 256 )
443
+ if ( textMaxCharCount <= 256 )
444
444
{
445
445
utf16TextArray = null ;
446
446
utf16Text = stackalloc char [ 256 ] ;
447
447
}
448
448
else
449
449
{
450
450
utf16TextArray = ArrayPool < char > . Shared . Rent ( textMaxCharCount ) ;
451
- utf16Text = utf16TextArray . AsSpan ( 0 , textMaxCharCount ) ;
451
+ utf16Text = utf16TextArray ;
452
452
}
453
453
454
454
OperationStatus utf8TextStatus = Utf8 . ToUtf16 ( utf8Text , utf16Text , out _ , out int utf16TextLength , replaceInvalidSequences : false ) ;
@@ -486,15 +486,15 @@ bool IUtf8SpanFormattable.TryFormat(Span<byte> utf8Destination, out int bytesWri
486
486
scoped Span < char > utf16Destination ;
487
487
int destinationMaxCharCount = Encoding . UTF8 . GetMaxCharCount ( utf8Destination . Length ) ;
488
488
489
- if ( destinationMaxCharCount < 256 )
489
+ if ( destinationMaxCharCount <= 256 )
490
490
{
491
491
utf16DestinationArray = null ;
492
492
utf16Destination = stackalloc char [ 256 ] ;
493
493
}
494
494
else
495
495
{
496
496
utf16DestinationArray = ArrayPool < char > . Shared . Rent ( destinationMaxCharCount ) ;
497
- utf16Destination = utf16DestinationArray . AsSpan ( 0 , destinationMaxCharCount ) ;
497
+ utf16Destination = utf16DestinationArray ;
498
498
}
499
499
500
500
if ( ! TryFormat ( utf16Destination , out int charsWritten , format , provider ) )
@@ -542,15 +542,15 @@ static TSelf IUtf8SpanParsable<TSelf>.Parse(ReadOnlySpan<byte> utf8Text, IFormat
542
542
scoped Span < char > utf16Text ;
543
543
int textMaxCharCount = Encoding . UTF8 . GetMaxCharCount ( utf8Text . Length ) ;
544
544
545
- if ( textMaxCharCount < 256 )
545
+ if ( textMaxCharCount <= 256 )
546
546
{
547
547
utf16TextArray = null ;
548
548
utf16Text = stackalloc char [ 256 ] ;
549
549
}
550
550
else
551
551
{
552
552
utf16TextArray = ArrayPool < char > . Shared . Rent ( textMaxCharCount ) ;
553
- utf16Text = utf16TextArray . AsSpan ( 0 , textMaxCharCount ) ;
553
+ utf16Text = utf16TextArray ;
554
554
}
555
555
556
556
OperationStatus utf8TextStatus = Utf8 . ToUtf16 ( utf8Text , utf16Text , out _ , out int utf16TextLength , replaceInvalidSequences : false ) ;
@@ -589,15 +589,15 @@ static bool IUtf8SpanParsable<TSelf>.TryParse(ReadOnlySpan<byte> utf8Text, IForm
589
589
scoped Span < char > utf16Text ;
590
590
int textMaxCharCount = Encoding . UTF8 . GetMaxCharCount ( utf8Text . Length ) ;
591
591
592
- if ( textMaxCharCount < 256 )
592
+ if ( textMaxCharCount <= 256 )
593
593
{
594
594
utf16TextArray = null ;
595
595
utf16Text = stackalloc char [ 256 ] ;
596
596
}
597
597
else
598
598
{
599
599
utf16TextArray = ArrayPool < char > . Shared . Rent ( textMaxCharCount ) ;
600
- utf16Text = utf16TextArray . AsSpan ( 0 , textMaxCharCount ) ;
600
+ utf16Text = utf16TextArray ;
601
601
}
602
602
603
603
OperationStatus utf8TextStatus = Utf8 . ToUtf16 ( utf8Text , utf16Text , out _ , out int utf16TextLength , replaceInvalidSequences : false ) ;
0 commit comments