internal static double?ReadDoubleWrapperLittleEndian(ref ReadOnlySpan <byte> buffer, ref ParserInternalState state)
 {
     // length:1 + tag:1 + value:8 = 10 bytes
     if (state.bufferPos + 10 <= state.bufferSize)
     {
         // The entire wrapper message is already contained in `buffer`.
         int length = buffer[state.bufferPos];
         if (length == 0)
         {
             state.bufferPos++;
             return(0D);
         }
         // tag:1 + value:8 = length of 9 bytes
         // field=1, type=64-bit = tag of 9
         if (length != 9 || buffer[state.bufferPos + 1] != 9)
         {
             return(ReadDoubleWrapperSlow(ref buffer, ref state));
         }
         state.bufferPos += 2;
         return(ParsingPrimitives.ParseDouble(ref buffer, ref state));
     }
     else
     {
         return(ReadDoubleWrapperSlow(ref buffer, ref state));
     }
 }
        internal static double?ReadDoubleWrapperSlow(ref ReadOnlySpan <byte> buffer, ref ParserInternalState state)
        {
            int length = ParsingPrimitives.ParseLength(ref buffer, ref state);

            if (length == 0)
            {
                return(0D);
            }
            int    finalBufferPos = state.totalBytesRetired + state.bufferPos + length;
            double result         = 0D;

            do
            {
                // field=1, type=64-bit = tag of 9
                if (ParsingPrimitives.ParseTag(ref buffer, ref state) == 9)
                {
                    result = ParsingPrimitives.ParseDouble(ref buffer, ref state);
                }
                else
                {
                    ParsingPrimitivesMessages.SkipLastField(ref buffer, ref state);
                }
            }while (state.totalBytesRetired + state.bufferPos < finalBufferPos);
            return(result);
        }
Beispiel #3
0
 public double ReadDouble()
 {
     return(ParsingPrimitives.ParseDouble(ref buffer, ref state));
 }