Skip to content

Commit 58b82f2

Browse files
committed
fix: increase perf of watching large file count
Fixes #1317 Originally a new Set was generated upon every individual file (or dir) watched. This typically doesn't take a long time, but if there's 10,000 files to watch, it's very, very slow. Moving this logic out to the ready event instead, cuts all the processing time of the watch right down.
1 parent f616258 commit 58b82f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/monitor/watch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ function watch() {
9191
}
9292

9393
watchedFiles.push(file);
94-
watchedFiles = Array.from(new Set(watchedFiles)); // ensure no dupes
95-
total = watchedFiles.length;
9694
bus.emit('watching', file);
9795
debug('watching dir: %s', file);
9896
});
9997
watcher.on('ready', function () {
98+
watchedFiles = Array.from(new Set(watchedFiles)); // ensure no dupes
99+
total = watchedFiles.length;
100100
watcher.ready = true;
101101
resolve(total);
102102
debugRoot('watch is complete');

0 commit comments

Comments
 (0)