From 381e2c52b9e5c3e1ad95fbeca09ca7f6c74871fc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 21 Apr 2016 16:13:20 -0700 Subject: [PATCH] lru. --- lib/bcoin/lru.js | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/lib/bcoin/lru.js b/lib/bcoin/lru.js index e54e3c11..8079f6b6 100644 --- a/lib/bcoin/lru.js +++ b/lib/bcoin/lru.js @@ -14,10 +14,9 @@ var assert = utils.assert; * @constructor * @param {Number} maxSize * @param {Function?} getSize - * @param {Function?} onRemove */ -function LRU(maxSize, getSize, onRemove) { +function LRU(maxSize, getSize) { if (!(this instanceof LRU)) return new LRU(maxSize, getSize); @@ -25,7 +24,6 @@ function LRU(maxSize, getSize, onRemove) { this.size = 0; this.maxSize = maxSize; this.getSize = this._createGetSize(getSize); - this.onRemove = onRemove; this.head = null; this.tail = null; @@ -88,8 +86,6 @@ LRU.prototype._compact = function _compact() { break; this.size -= this._getSize(item); delete this.data[item.key]; - if (this.onRemove) - this.onRemove(item.key, item.value); next = item.next; item.prev = null; item.next = null; @@ -114,8 +110,6 @@ LRU.prototype.reset = function reset() { for (item = this.head; item; item = next) { delete this.data[item.key]; - if (this.onRemove) - this.onRemove(item.key, item.value); next = item.next; item.prev = null; item.next = null; @@ -213,8 +207,6 @@ LRU.prototype.remove = function remove(key) { this.size -= this._getSize(item); delete this.data[key]; - if (this.onRemove) - this.onRemove(item.key, item.value); this._removeList(item); @@ -313,19 +305,4 @@ LRU.prototype.toArray = function toArray() { return items; }; -/** - * Create an iterator with a `next` method. - * @returns {Function} - */ - -LRU.prototype.iterator = function iterator() { - return { - item: { next: this.head }, - next: function() { - this.item = this.item.next; - return this.item; - } - }; -}; - module.exports = LRU;