Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 38fe5c6

Browse files
committed
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
1 parent 167812b commit 38fe5c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bin/node-sass

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ function watch(options, emitter) {
268268

269269
// Add children to watcher
270270
graph.visitDescendents(file, function(child) {
271-
gaze.add(child);
271+
if (watch.indexOf(child) === -1) {
272+
watch.push(child);
273+
gaze.add(child);
274+
}
272275
});
273276
files.forEach(function(file) {
274277
if (path.basename(file)[0] !== '_') {

0 commit comments

Comments
 (0)