コード例 #1
0
        internal static int FindNextCrLf(BufferReader reader) // very deliberately not ref; want snapshot
        {
            // is it in the current span? (we need to handle the offsets differently if so)

            int  totalSkipped   = 0;
            bool haveTrailingCR = false;

            do
            {
                if (reader.RemainingThisSpan == 0)
                {
                    continue;
                }

                var span = reader.SlicedSpan;
                if (haveTrailingCR)
                {
                    if (span[0] == '\n')
                    {
                        return(totalSkipped - 1);
                    }
                }

                int found = span.VectorSafeIndexOfCRLF();
                if (found >= 0)
                {
                    return(totalSkipped + found);
                }

                haveTrailingCR = span[span.Length - 1] == '\r';
                totalSkipped  += span.Length;
            }while (reader.FetchNextSegment());
            return(-1);
        }
コード例 #2
0
        internal static int FindNext(BufferReader reader, byte value) // very deliberately not ref; want snapshot
        {
            int totalSkipped = 0;

            do
            {
                if (reader.RemainingThisSpan == 0)
                {
                    continue;
                }

                var span  = reader.SlicedSpan;
                int found = span.VectorSafeIndexOf(value);
                if (found >= 0)
                {
                    return(totalSkipped + found);
                }

                totalSkipped += span.Length;
            } while (reader.FetchNextSegment());
            return(-1);
        }