Blocks which complete synchronously have the completion de-nested. Big speed improvement, not quite sure why yet.

This commit is contained in:
Christian Williams 2009-10-12 21:23:57 -05:00
parent a3ed49a5ed
commit b7549196da
1 changed files with 17 additions and 3 deletions

View File

@ -29,12 +29,20 @@ jasmine.Queue.prototype.isRunning = function() {
return this.running;
};
var nestLevel = 0;
jasmine.Queue.UNROLL = true;
jasmine.Queue.prototype.next_ = function() {
var self = this;
if (self.index < self.blocks.length) {
self.blocks[self.index].execute(function () {
var calledSynchronously = true;
var completedSynchronously = false;
var onComplete = function () {
if (jasmine.Queue.UNROLL && calledSynchronously) {
completedSynchronously = true;
return;
}
self.offset = 0;
self.index++;
@ -47,7 +55,13 @@ jasmine.Queue.prototype.next_ = function() {
} else {
self.next_();
}
});
};
self.blocks[self.index].execute(onComplete);
calledSynchronously = false;
if (completedSynchronously) {
onComplete();
}
} else {
self.running = false;
if (self.onComplete) {