Commit 38fe5c69 by xzyfer

Make the watcher more responsive to child changes

Watching for changes on files with lots of `@import`s had a
significant regression in responsiveness in #1745.

The regression was caused by calling `gaze.add` unnecessarily. We
only need to call `gaze.add` on files that aren't currently being
watched.

At the time I confirmed that calling `gaze.add` in files that were
being watched wouldn't result in a leak or multiple events being
fired. I however assumed calling `gaze.add` for already watched
files would be very cheap.

Fixes #1869
parent 167812b6
...@@ -268,7 +268,10 @@ function watch(options, emitter) { ...@@ -268,7 +268,10 @@ function watch(options, emitter) {
// Add children to watcher // Add children to watcher
graph.visitDescendents(file, function(child) { graph.visitDescendents(file, function(child) {
gaze.add(child); if (watch.indexOf(child) === -1) {
watch.push(child);
gaze.add(child);
}
}); });
files.forEach(function(file) { files.forEach(function(file) {
if (path.basename(file)[0] !== '_') { if (path.basename(file)[0] !== '_') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment