Skip to content

Commit

Permalink
Make forEach even faster
Browse files Browse the repository at this point in the history
  • Loading branch information
pfleidi committed Oct 20, 2010
1 parent b80b165 commit 561c0ec
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/dirty/dirty.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ Dirty.prototype.rm = function(key, cb) {
};

Dirty.prototype.forEach = function(fn) {
var self = this,
StopIteration = new Error("StopIteration");

try {
this._keys.forEach(function (key) {
if (fn(key, self._docs[key]) === false) {
throw StopIteration;
}
});
} catch (ex) {
if (ex != StopIteration) throw ex;
for (var i = 0; i < this._keys.length; i++) {
var key = this._keys[i];
if (fn(key, this._docs[key]) === false) {
break;
}
}

};

Dirty.prototype._load = function() {
Expand Down

0 comments on commit 561c0ec

Please sign in to comment.