Skip to content

Commit

Permalink
fix: increase perf of watching large file count
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
remy committed May 5, 2018
1 parent f616258 commit 58b82f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/monitor/watch.js
Expand Up @@ -91,12 +91,12 @@ function watch() {
}

watchedFiles.push(file);
watchedFiles = Array.from(new Set(watchedFiles)); // ensure no dupes
total = watchedFiles.length;
bus.emit('watching', file);
debug('watching dir: %s', file);
});
watcher.on('ready', function () {
watchedFiles = Array.from(new Set(watchedFiles)); // ensure no dupes
total = watchedFiles.length;
watcher.ready = true;
resolve(total);
debugRoot('watch is complete');
Expand Down

0 comments on commit 58b82f2

Please sign in to comment.