コード例 #1
0
        internal unsafe void MinimalBaseline(string path, PathSegment *segments, int maxCount)
        {
            var start  = 1;
            var length = path.Length - start;

            segments[0] = new PathSegment(start, length);
        }
コード例 #2
0
        internal unsafe void NaiveBaseline(string path, PathSegment *segments, int maxCount)
        {
            int count = 0;
            int start = 1; // Paths always start with a leading /
            int end;

            while ((end = path.IndexOf('/', start)) >= 0 && count < maxCount)
            {
                segments[count++] = new PathSegment(start, end - start);
                start             = end + 1; // resume search after the current character
            }

            // Residue
            var length = path.Length - start;

            if (length > 0 && count < maxCount)
            {
                segments[count++] = new PathSegment(start, length);
            }
        }
コード例 #3
0
        // This section tokenizes the path by marking the sequence of slashes, and their
        // and the length of the text between them.
        //
        // If there is residue (text after last slash) then the length of the segment will
        // computed based on the string length.
        public static unsafe int Tokenize(string path, PathSegment *segments, int maxCount)
        {
            int count = 0;
            int start = 1; // Paths always start with a leading /
            int end;
            var span = path.AsSpan(start);

            while ((end = span.IndexOf('/')) >= 0 && count < maxCount)
            {
                segments[count++] = new PathSegment(start, end);
                start            += end + 1; // resume search after the current character
                span = path.AsSpan(start);
            }

            // Residue
            var length = span.Length;

            if (length > 0 && count < maxCount)
            {
                segments[count++] = new PathSegment(start, length);
            }

            return(count);
        }
コード例 #4
0
 public unsafe abstract int GetDestination(PathSegment *segments, int depth, string path);