ignore icon indicating copy to clipboard operation
ignore copied to clipboard

Support ReadOnlySpan<char> for IsMatch()

Open kjpgit opened this issue 1 year ago • 1 comments

Example:

  public bool IsMatch(ReadOnlySpan<char> input)
    {
        return parsedRegex != null && parsedRegex.IsMatch(input);
    }

Just add that signature in addition to the one taking string.

This reduces my time of scanning 200K files from 1.79 --> 1.57 seconds.

It's because the ReadOnlySpan supports an efficient Slice() operation, so I'm not scanning the part of the path above where the .gitignore file resides.

I'm the author of ViLark, a file chooser for vim, sort of like fzf.

And thanks for this library, it helps a lot. Although I am getting very slow performance with a wildcard like '*.pyc', I might dig into that if I have time.

kjpgit avatar Sep 12 '23 01:09 kjpgit

Thanks for the suggestion. Feel free to raise a PR, otherwise I will try to get to this tomorrow.

Yeah always good to improve performance. The library uses a bunch of regex, which I tried to follow best practices for, but maybe there can be improvements there.

goelhardik avatar Sep 12 '23 01:09 goelhardik