-
-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to faster micromatch lib #332
Comments
Check out https://github.com/micromatch/glob-fs and https://github.com/micromatch/bash-glob, both created by micromatch's author. |
No. There are several cases where micromatch does not implement bash semantics as faithfully as this library requires. These are explained in detail on the readme. Also, the benefit of using minimatch is that I maintain it, so when it needs to change to support glob, that's very easy for me to do. Both of these would be dealbreakers anyway. Furthermore, please be aware that benchmarks must be read very carefully, and can easily be misleading, even if the creator of those benchmarks isn't intending them to be. The actual matching of glob is (a) not the slow part, and (b) not significantly improved by using micromatch's patterns rather than minimatch's. Micromatch creates patterns faster, but that happens exactly 1 time per pattern per glob operation. The I had wondered if maybe minimatch's anchoring and dot-preventing lookaheads imposed a performance penalty. Towards that end, I've tested extensively how this impacts the actual glob performance, if there's some benefit to using the regular expressions generated by picomatch or micromatch. There really isn't. Even just running them in a tight loop calling Also, since the most common patterns, by far, in use in glob expressions are |
Thank you for your answer @isaacs. I wonder why these statements are made then? https://github.com/micromatch/micromatch#why-use-micromatch
How does
|
I'm not really the one to ask about those statements, since I didn't make them ;) The differences between Bash and micromatch/picomatch that I've found are explained in some detail in the readme on this repo, under the "Comparisons with Other JavaScript Glob Implementations" heading. (One point that's missed there, the POSIX standard classes are actually not as accurate as they are in minimatch, for example Micromatch is faster, as I said, but not in any way that matters for glob's use case. If you're evaluating a lot of patterns to essentially test once and throw away, especially if it's in a hot path, yeah, it'll be worthwhile to use micromatch or picomatch if the bash coherence isn't a dealbreaker for you (and there are a lot of cases like that). But glob doesn't do that, it parses the pattern one time in way less than 1ms (whether using micromatch or minimatch), then spends absolute ages by comparison doing a ton of file system operations. The security thing is sort of weird to bring up. Minimatch had a redos vulnerability that was reported and swiftly fixed. I assume that micromatch would have done the same thing (or may even have done so in the past), as this is a pretty normal thing in any software library that processes strings. So I'm not saying one is "better" than the other, just that the tradeoffs of using minimatch make it a much better, um, match for this library. |
Alright. Thank you for taking the time to give an thorough answer. |
See: https://github.com/jonschlinkert/micromatch#why-switch-to-micromatch
The text was updated successfully, but these errors were encountered: