-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-optimize patterns prior to parsing
Make various equivalent edits to the glob parts array to avoid (as much as possible) situations that result in significant increases in work required to walk folder trees in node-glob. BREAKING CHANGES: In some cases, with very complicated patterns, this actually reduces the performance of the full makeRe regular expression. Also, because `..` now swallows any pattern ahead of it (other than globstar, dot, double-dot, and empty), this means that a pattern like `a/../b` will *not* match the string `a/**/b`, because it shrinks to just `b`. But it also means that patterns *will* match against `path.join()`'ed strings, whereas previously they would not. It would be possible to handle the second issue in `.match()` by walking back on path portions `..`, which is worth considering if this causes issues as people who use this in other situations upgrade to the new version. And while the full makeRe pattern is quite a bit longer in the case of complicated patterns, having multiple simpler patterns can pretty dramatically *improve* performance in the `.match()` method. Also, duplicate and extraneous patterns are removed from the pattern set. For example, `a/{b,b,*}/c` will be parsed the same as `a/*/c`, since `*` can match against `b`, and the two `a/b/c` expansions are identical.
- Loading branch information
Showing
5 changed files
with
940 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.