Skip to content

Commit

Permalink
Make the watcher more responsive to child changes
Browse files Browse the repository at this point in the history
Watching for changes on files with lots of `@import`s had a
significant regression in responsiveness in sass#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 sass#1869
  • Loading branch information
xzyfer committed Jan 28, 2017
1 parent 167812b commit ed290be
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ function watch(options, emitter) {

// Add children to watcher
graph.visitDescendents(file, function(child) {
gaze.add(child);
if (watch.indexOf(child) == -1) {
watch.push(child);
gaze.add(child);
}
});
files.forEach(function(file) {
if (path.basename(file)[0] !== '_') {
Expand Down

0 comments on commit ed290be

Please sign in to comment.