Commit 066ccf8
Improve the performance when checking broad glob patterns. (#14481)
In a large project, it's costly to repeatedly call the
function `micromatch.isMatch` that parses a glob pattern,
creates a regular expression, and tests the path name
against the regular expression. To optimize performance,
it's important to cache the parsing and creating process
before entering the loop.
For example, the content configuration in a project
looks like this
`['./pages/**/*.{ts,js}', './node_modules/pages/**/*.{ts,js}']`.
If the project has 10000 matched files and 10 glob patterns,
the function `micromatch.isMatch` will be called 100000 times.
---
Co-authored-by: Robin Malfait <[email protected]>1 parent e8614a2 commit 066ccf8
2 files changed
+23
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
216 | 229 | | |
217 | 230 | | |
218 | 231 | | |
| |||
225 | 238 | | |
226 | 239 | | |
227 | 240 | | |
228 | | - | |
| 241 | + | |
229 | 242 | | |
230 | 243 | | |
231 | 244 | | |
232 | | - | |
233 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
234 | 248 | | |
235 | 249 | | |
236 | 250 | | |
| |||
0 commit comments