private static unsafe bool IsMatch(
            StringPart input,
            StringPart pattern,
            ValueWildcardOptions options = default)
        {
            int estimatedStackSize            = pattern.Length / AverageCharactersPerInstruction;
            Span <WildcardInstruction> buffer = estimatedStackSize > ParserStackAllocThreshold
                ? default
                : stackalloc WildcardInstruction[estimatedStackSize];

            var parser = new WildcardParser(buffer, pattern);

            try
            {
                parser.Parse();
                int stepCount = parser.Steps.Length;
                if (stepCount <= estimatedStackSize && !buffer.IsEmpty)
                {
                    return(IsMatch(input, buffer.Slice(0, stepCount), options));
                }

                return(IsMatch(input, parser.Steps.ToArray(), options));
            }
            finally
            {
                parser.Dispose();
            }
        }
 /// <summary>
 /// Indicates whether the specified wildcard pattern finds a match
 /// in the specified input string.
 /// </summary>
 /// <param name="input">The string to search for a match.</param>
 /// <param name="pattern">The wildcard pattern to match.</param>
 /// <param name="options">Options that alter the behavior of the matcher.</param>
 /// <returns>
 /// <c>true</c> if the regular expression finds a match; otherwise,
 /// <c>false</c>.
 /// </returns>
 public static unsafe bool IsMatch(string input, string pattern, ValueWildcardOptions options)
 {
     fixed(char *pInput = input)
     fixed(char *pPattern = pattern)
     {
         return(WildcardInterpreter.IsMatch(pInput, input.Length, pPattern, pattern.Length, options));
     }
 }
 internal static unsafe bool IsMatch(
     char *input,
     int inputLength,
     char *pattern,
     int patternLength,
     ValueWildcardOptions options = default)
 {
     return(IsMatch(
                new StringPart(input, inputLength),
                new StringPart(pattern, patternLength),
                options));
 }
        internal static unsafe bool IsMatch(
            StringPart input,
            ReadOnlySpan <WildcardInstruction> instructions,
            ValueWildcardOptions options = default)
        {
            Span <Frame> state = instructions.Length > FrameStackAllocThreshold
                ? new Frame[instructions.Length]
                : stackalloc Frame[instructions.Length];

            var interpreter = new WildcardInterpreter(instructions, state, input, options);

            return(interpreter.IsMatch());
        }
 private WildcardInterpreter(
     ReadOnlySpan <WildcardInstruction> instructions,
     Span <Frame> frames,
     StringPart source,
     ValueWildcardOptions options)
 {
     _instructions    = instructions;
     _frames          = frames;
     _source          = source;
     _culture         = options.Culture;
     _isCaseSensitive = options.IsCaseSensitive;
     _index           = 0;
     _textPosition    = 0;
 }