Skip to content

Commit

Permalink
Optimize delete operations on taskrunner queue. Closes GH-133.
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon authored and shama committed Jun 23, 2013
1 parent ede6a10 commit ec87f65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasks/lib/taskrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,22 @@ module.exports = function(grunt) {
if (self.running === false) { return; }
self.running = false;
var time = 0;
self.queue.forEach(function(name, i) {
for (var i = 0, len = self.queue.length; i < len; ++i) {
var name = self.queue[i];
var target = self.targets[name];
if (!target) { return; }
if (target.startedAt !== false) {
time += target.complete();
self.queue[i] = null;
self.queue.splice(i--, 1);
len--;

// if we're just livereloading and no tasks
// it can happen too fast and we dont report it
if (target.options.livereload && target.tasks.length < 1) {
time += 0.0001;
}
}
});
}
var elapsed = (time > 0) ? Number(time / 1000) : 0;
self.changedFiles = Object.create(null);
self.emit('end', elapsed);
Expand Down

0 comments on commit ec87f65

Please sign in to comment.