internal unsafe void MinimalBaseline(string path, PathSegment *segments, int maxCount) { var start = 1; var length = path.Length - start; segments[0] = new PathSegment(start, length); }
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); } }
// 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); }
public unsafe abstract int GetDestination(PathSegment *segments, int depth, string path);