Skip to content

Commit

Permalink
Merge pull request #235 from wyicwx/master
Browse files Browse the repository at this point in the history
fix some  performance issues
  • Loading branch information
shama authored Mar 25, 2017
2 parents 46d6c2a + b0e8b95 commit b9b8257
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/gaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ Gaze.prototype.relative = function (dir, unixify) {

// Adds files and dirs to watched
Gaze.prototype._addToWatched = function (files) {
var dirs = [];

for (var i = 0; i < files.length; i++) {
var file = files[i];
var filepath = path.resolve(this.options.cwd, file);
Expand All @@ -285,6 +287,13 @@ Gaze.prototype._addToWatched = function (files) {
if (file.slice(-1) === '/') { filepath += path.sep; }
helper.objectPush(this._watched, path.dirname(filepath) + path.sep, filepath);

dirs.push(dirname);
}

dirs = helper.unique(dirs);

for (var k = 0; k < dirs.length; k++) {
dirname = dirs[k];
// add folders into the mix
var readdir = fs.readdirSync(dirname);
for (var j = 0; j < readdir.length; j++) {
Expand All @@ -294,6 +303,7 @@ Gaze.prototype._addToWatched = function (files) {
}
}
}

return this;
};

Expand Down

0 comments on commit b9b8257

Please sign in to comment.