Use an object literal rather than a class for LRUCache entries
This commit is contained in:
+11
-31
@@ -225,7 +225,12 @@ ol.structs.LRUCache.prototype.pop = function() {
|
|||||||
ol.structs.LRUCache.prototype.set = function(key, value) {
|
ol.structs.LRUCache.prototype.set = function(key, value) {
|
||||||
goog.asserts.assert(!(key in {}));
|
goog.asserts.assert(!(key in {}));
|
||||||
goog.asserts.assert(!(key in this.entries_));
|
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_)) {
|
if (goog.isNull(this.newest_)) {
|
||||||
this.oldest_ = entry;
|
this.oldest_ = entry;
|
||||||
} else {
|
} else {
|
||||||
@@ -237,35 +242,10 @@ ol.structs.LRUCache.prototype.set = function(key, value) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @typedef {{key: string,
|
||||||
* @private
|
* newer: ol.structs.LRUCacheEntry_,
|
||||||
* @param {string} key Key.
|
* older: ol.structs.LRUCacheEntry_,
|
||||||
* @param {*} value Value.
|
* value: *}}
|
||||||
* @param {ol.structs.LRUCacheEntry_} newer Newer.
|
|
||||||
* @param {ol.structs.LRUCacheEntry_} older Older.
|
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCacheEntry_ = function(key, value, newer, older) {
|
ol.structs.LRUCacheEntry_;
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.key = key;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {*}
|
|
||||||
*/
|
|
||||||
this.value = value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.structs.LRUCacheEntry_}
|
|
||||||
*/
|
|
||||||
this.newer = newer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.structs.LRUCacheEntry_}
|
|
||||||
*/
|
|
||||||
this.older = older;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user