From 369f5a6171b13fdf5edab1c7f6ebb74e1a7b19f9 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 29 Sep 2015 15:25:32 +0200 Subject: [PATCH] Remove goog.isNull in lrucache class --- src/ol/structs/lrucache.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ol/structs/lrucache.js b/src/ol/structs/lrucache.js index 656524ad04..cf02b66ed7 100644 --- a/src/ol/structs/lrucache.js +++ b/src/ol/structs/lrucache.js @@ -49,25 +49,25 @@ ol.structs.LRUCache.prototype.assertValid = function() { if (this.count_ === 0) { goog.asserts.assert(goog.object.isEmpty(this.entries_), 'entries must be an empty object (count = 0)'); - goog.asserts.assert(goog.isNull(this.oldest_), + goog.asserts.assert(!this.oldest_, 'oldest must be null (count = 0)'); - goog.asserts.assert(goog.isNull(this.newest_), + goog.asserts.assert(!this.newest_, 'newest must be null (count = 0)'); } else { goog.asserts.assert(goog.object.getCount(this.entries_) == this.count_, 'number of entries matches count'); - goog.asserts.assert(!goog.isNull(this.oldest_), + goog.asserts.assert(this.oldest_, 'we have an oldest entry'); - goog.asserts.assert(goog.isNull(this.oldest_.older), + goog.asserts.assert(!this.oldest_.older, 'no entry is older than oldest'); - goog.asserts.assert(!goog.isNull(this.newest_), + goog.asserts.assert(this.newest_, 'we have a newest entry'); - goog.asserts.assert(goog.isNull(this.newest_.newer), + goog.asserts.assert(!this.newest_.newer, 'no entry is newer than newest'); var i, entry; var older = null; i = 0; - for (entry = this.oldest_; !goog.isNull(entry); entry = entry.newer) { + for (entry = this.oldest_; entry; entry = entry.newer) { goog.asserts.assert(entry.older === older, 'entry.older links to correct older'); older = entry; @@ -76,7 +76,7 @@ ol.structs.LRUCache.prototype.assertValid = function() { goog.asserts.assert(i == this.count_, 'iterated correct amount of times'); var newer = null; i = 0; - for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) { + for (entry = this.newest_; entry; entry = entry.older) { goog.asserts.assert(entry.newer === newer, 'entry.newer links to correct newer'); newer = entry; @@ -117,7 +117,7 @@ ol.structs.LRUCache.prototype.containsKey = function(key) { */ ol.structs.LRUCache.prototype.forEach = function(f, opt_this) { var entry = this.oldest_; - while (!goog.isNull(entry)) { + while (entry) { f.call(opt_this, entry.value_, entry.key_, this); entry = entry.newer; } @@ -163,7 +163,7 @@ ol.structs.LRUCache.prototype.getKeys = function() { var keys = new Array(this.count_); var i = 0; var entry; - for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) { + for (entry = this.newest_; entry; entry = entry.older) { keys[i++] = entry.key_; } goog.asserts.assert(i == this.count_, 'iterated correct number of times'); @@ -178,7 +178,7 @@ ol.structs.LRUCache.prototype.getValues = function() { var values = new Array(this.count_); var i = 0; var entry; - for (entry = this.newest_; !goog.isNull(entry); entry = entry.older) { + for (entry = this.newest_; entry; entry = entry.older) { values[i++] = entry.value_; } goog.asserts.assert(i == this.count_, 'iterated correct number of times'); @@ -190,7 +190,7 @@ ol.structs.LRUCache.prototype.getValues = function() { * @return {T} Last value. */ ol.structs.LRUCache.prototype.peekLast = function() { - goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null'); + goog.asserts.assert(this.oldest_, 'oldest must not be null'); return this.oldest_.value_; }; @@ -199,7 +199,7 @@ ol.structs.LRUCache.prototype.peekLast = function() { * @return {string} Last key. */ ol.structs.LRUCache.prototype.peekLastKey = function() { - goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null'); + goog.asserts.assert(this.oldest_, 'oldest must not be null'); return this.oldest_.key_; }; @@ -208,17 +208,17 @@ ol.structs.LRUCache.prototype.peekLastKey = function() { * @return {T} value Value. */ ol.structs.LRUCache.prototype.pop = function() { - goog.asserts.assert(!goog.isNull(this.oldest_), 'oldest must not be null'); - goog.asserts.assert(!goog.isNull(this.newest_), 'newest must not be null'); + goog.asserts.assert(this.oldest_, 'oldest must not be null'); + goog.asserts.assert(this.newest_, 'newest must not be null'); var entry = this.oldest_; goog.asserts.assert(entry.key_ in this.entries_, 'oldest is indexed in entries'); delete this.entries_[entry.key_]; - if (!goog.isNull(entry.newer)) { + if (entry.newer) { entry.newer.older = null; } this.oldest_ = entry.newer; - if (goog.isNull(this.oldest_)) { + if (!this.oldest_) { this.newest_ = null; } --this.count_; @@ -241,7 +241,7 @@ ol.structs.LRUCache.prototype.set = function(key, value) { older: this.newest_, value_: value }; - if (goog.isNull(this.newest_)) { + if (!this.newest_) { this.oldest_ = entry; } else { this.newest_.newer = entry;