shama / gaze

:crystal_ball: A globbing fs.watch wrapper built from the best parts of other fine watch libs.
MIT License
1.15k stars 168 forks source link

fix some performance issues #235

Closed wyicwx closed 7 years ago

wyicwx commented 7 years ago

I use glob to match some files, these files are saving in same folder, the following code will be executed more than once, because dirname is same, it make performance issues, the code at gaze.js line 289 in _addToWatched function.

var readdir = fs.readdirSync(dirname);

for (var j = 0; j < readdir.length; j++) {

  var dirfile = path.join(dirname, readdir[j]);

  if (fs.lstatSync(dirfile).isDirectory()) {

    helper.objectPush(this._watched, dirname, dirfile + path.sep);
  }
}
alexgorbatchev commented 7 years ago

@shama this looks like a good suggestion.

shama commented 7 years ago

Thanks!