Skip to content

Commit 3edea66

Browse files
TrottRafaelGSS
authored andcommitted
fs: improve globSync performance
PR-URL: #57725 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 3cdf8ec commit 3edea66

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/internal/fs/glob.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ class Glob {
331331
const fullpath = resolve(this.#root, path);
332332

333333
// If path is a directory, add trailing slash and test patterns again.
334-
// TODO(Trott): Would running #isExcluded() first and checking isDirectory() only
335-
// if it matches be more performant in the typical use case? #isExcluded()
336-
// is often ()=>false which is about as optimizable as a function gets.
337-
if (this.#cache.statSync(fullpath).isDirectory() && this.#isExcluded(`${fullpath}/`)) {
334+
if (this.#isExcluded(`${fullpath}/`) && this.#cache.statSync(fullpath).isDirectory()) {
338335
return;
339336
}
340337

0 commit comments

Comments
 (0)