@@ -13,6 +13,9 @@ sealed class BigIntegerNumericConverter : PgStreamingConverter<BigInteger>
1313
1414 public override BigInteger Read ( PgReader reader )
1515 {
16+ if ( reader . ShouldBuffer ( sizeof ( short ) ) )
17+ reader . Buffer ( sizeof ( short ) ) ;
18+
1619 var digitCount = reader . ReadInt16 ( ) ;
1720 short [ ] ? digitsFromPool = null ;
1821 var digits = ( digitCount <= StackAllocByteThreshold / sizeof ( short )
@@ -37,7 +40,9 @@ public override ValueTask<BigInteger> ReadAsync(PgReader reader, CancellationTok
3740
3841 static async ValueTask < BigInteger > AsyncCore ( PgReader reader , CancellationToken cancellationToken )
3942 {
40- await reader . BufferAsync ( PgNumeric . GetByteCount ( 0 ) , cancellationToken ) . ConfigureAwait ( false ) ;
43+ if ( reader . ShouldBuffer ( sizeof ( short ) ) )
44+ await reader . BufferAsync ( sizeof ( short ) , cancellationToken ) . ConfigureAwait ( false ) ;
45+
4146 var digitCount = reader . ReadInt16 ( ) ;
4247 var digits = new ArraySegment < short > ( ArrayPool < short > . Shared . Rent ( digitCount ) , 0 , digitCount ) ;
4348 var value = ConvertTo ( await NumericConverter . ReadAsync ( reader , digits , cancellationToken ) . ConfigureAwait ( false ) ) ;
@@ -187,7 +192,7 @@ static T ConvertTo(in PgNumeric.Builder numeric)
187192
188193static class NumericConverter
189194{
190- public static int DecimalBasedMaxByteCount = PgNumeric . GetByteCount ( PgNumeric . Builder . MaxDecimalNumericDigits ) ;
195+ public static readonly int DecimalBasedMaxByteCount = PgNumeric . GetByteCount ( PgNumeric . Builder . MaxDecimalNumericDigits ) ;
191196
192197 public static PgNumeric . Builder Read ( PgReader reader , Span < short > digits )
193198 {
0 commit comments