From c37837ba34a406d113dad42d4af3232f1c45b3a9 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 6 Feb 2013 08:42:43 +0100 Subject: [PATCH] Use an object literal rather than a class for LRUCache entries --- src/ol/structs/lrucache.js | 42 ++++++++++---------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/src/ol/structs/lrucache.js b/src/ol/structs/lrucache.js index 863859bdba..909dbcb2c1 100644 --- a/src/ol/structs/lrucache.js +++ b/src/ol/structs/lrucache.js @@ -225,7 +225,12 @@ ol.structs.LRUCache.prototype.pop = function() { ol.structs.LRUCache.prototype.set = function(key, value) { goog.asserts.assert(!(key in {})); goog.asserts.assert(!(key in this.entries_)); - var entry = new ol.structs.LRUCacheEntry_(key, value, null, this.newest_); + var entry = { + key: key, + newer: null, + older: this.newest_, + value: value + }; if (goog.isNull(this.newest_)) { this.oldest_ = entry; } else { @@ -237,35 +242,10 @@ ol.structs.LRUCache.prototype.set = function(key, value) { }; - /** - * @constructor - * @private - * @param {string} key Key. - * @param {*} value Value. - * @param {ol.structs.LRUCacheEntry_} newer Newer. - * @param {ol.structs.LRUCacheEntry_} older Older. + * @typedef {{key: string, + * newer: ol.structs.LRUCacheEntry_, + * older: ol.structs.LRUCacheEntry_, + * value: *}} */ -ol.structs.LRUCacheEntry_ = function(key, value, newer, older) { - - /** - * @type {string} - */ - this.key = key; - - /** - * @type {*} - */ - this.value = value; - - /** - * @type {ol.structs.LRUCacheEntry_} - */ - this.newer = newer; - - /** - * @type {ol.structs.LRUCacheEntry_} - */ - this.older = older; - -}; +ol.structs.LRUCacheEntry_;