Remove ol.DEBUG

This commit is contained in:
Tim Schaub
2016-12-29 09:09:24 -07:00
parent 7b9690a691
commit 137cdc04c8
128 changed files with 309 additions and 2027 deletions

View File

@@ -2,7 +2,6 @@ goog.provide('ol.structs.LRUCache');
goog.require('ol');
goog.require('ol.asserts');
goog.require('ol.obj');
/**
@@ -42,53 +41,6 @@ ol.structs.LRUCache = function() {
};
if (ol.DEBUG) {
/**
* FIXME empty description for jsdoc
*/
ol.structs.LRUCache.prototype.assertValid = function() {
if (this.count_ === 0) {
console.assert(ol.obj.isEmpty(this.entries_),
'entries must be an empty object (count = 0)');
console.assert(!this.oldest_,
'oldest must be null (count = 0)');
console.assert(!this.newest_,
'newest must be null (count = 0)');
} else {
console.assert(Object.keys(this.entries_).length == this.count_,
'number of entries matches count');
console.assert(this.oldest_,
'we have an oldest entry');
console.assert(!this.oldest_.older,
'no entry is older than oldest');
console.assert(this.newest_,
'we have a newest entry');
console.assert(!this.newest_.newer,
'no entry is newer than newest');
var i, entry;
var older = null;
i = 0;
for (entry = this.oldest_; entry; entry = entry.newer) {
console.assert(entry.older === older,
'entry.older links to correct older');
older = entry;
++i;
}
console.assert(i == this.count_, 'iterated correct amount of times');
var newer = null;
i = 0;
for (entry = this.newest_; entry; entry = entry.older) {
console.assert(entry.newer === newer,
'entry.newer links to correct newer');
newer = entry;
++i;
}
console.assert(i == this.count_, 'iterated correct amount of times');
}
};
}
/**
* FIXME empty description for jsdoc
*/
@@ -169,7 +121,6 @@ ol.structs.LRUCache.prototype.getKeys = function() {
for (entry = this.newest_; entry; entry = entry.older) {
keys[i++] = entry.key_;
}
ol.DEBUG && console.assert(i == this.count_, 'iterated correct number of times');
return keys;
};
@@ -184,7 +135,6 @@ ol.structs.LRUCache.prototype.getValues = function() {
for (entry = this.newest_; entry; entry = entry.older) {
values[i++] = entry.value_;
}
ol.DEBUG && console.assert(i == this.count_, 'iterated correct number of times');
return values;
};
@@ -193,7 +143,6 @@ ol.structs.LRUCache.prototype.getValues = function() {
* @return {T} Last value.
*/
ol.structs.LRUCache.prototype.peekLast = function() {
ol.DEBUG && console.assert(this.oldest_, 'oldest must not be null');
return this.oldest_.value_;
};
@@ -202,7 +151,6 @@ ol.structs.LRUCache.prototype.peekLast = function() {
* @return {string} Last key.
*/
ol.structs.LRUCache.prototype.peekLastKey = function() {
ol.DEBUG && console.assert(this.oldest_, 'oldest must not be null');
return this.oldest_.key_;
};
@@ -211,11 +159,7 @@ ol.structs.LRUCache.prototype.peekLastKey = function() {
* @return {T} value Value.
*/
ol.structs.LRUCache.prototype.pop = function() {
ol.DEBUG && console.assert(this.oldest_, 'oldest must not be null');
ol.DEBUG && console.assert(this.newest_, 'newest must not be null');
var entry = this.oldest_;
ol.DEBUG && console.assert(entry.key_ in this.entries_,
'oldest is indexed in entries');
delete this.entries_[entry.key_];
if (entry.newer) {
entry.newer.older = null;
@@ -244,8 +188,6 @@ ol.structs.LRUCache.prototype.replace = function(key, value) {
* @param {T} value Value.
*/
ol.structs.LRUCache.prototype.set = function(key, value) {
ol.DEBUG && console.assert(!(key in {}),
'key is not a standard property of objects (e.g. "__proto__")');
ol.asserts.assert(!(key in this.entries_),
16); // Tried to set a value for a key that is used already
var entry = /** @type {ol.LRUCacheEntry} */ ({

View File

@@ -62,29 +62,6 @@ ol.structs.PriorityQueue = function(priorityFunction, keyFunction) {
ol.structs.PriorityQueue.DROP = Infinity;
if (ol.DEBUG) {
/**
* FIXME empty description for jsdoc
*/
ol.structs.PriorityQueue.prototype.assertValid = function() {
var elements = this.elements_;
var priorities = this.priorities_;
var n = elements.length;
console.assert(priorities.length == n);
var i, priority;
for (i = 0; i < (n >> 1) - 1; ++i) {
priority = priorities[i];
console.assert(priority <= priorities[this.getLeftChildIndex_(i)],
'priority smaller than or equal to priority of left child (%s <= %s)',
priority, priorities[this.getLeftChildIndex_(i)]);
console.assert(priority <= priorities[this.getRightChildIndex_(i)],
'priority smaller than or equal to priority of right child (%s <= %s)',
priority, priorities[this.getRightChildIndex_(i)]);
}
};
}
/**
* FIXME empty description for jsdoc
*/
@@ -101,8 +78,6 @@ ol.structs.PriorityQueue.prototype.clear = function() {
*/
ol.structs.PriorityQueue.prototype.dequeue = function() {
var elements = this.elements_;
ol.DEBUG && console.assert(elements.length > 0,
'must have elements in order to be able to dequeue');
var priorities = this.priorities_;
var element = elements[0];
if (elements.length == 1) {
@@ -114,8 +89,6 @@ ol.structs.PriorityQueue.prototype.dequeue = function() {
this.siftUp_(0);
}
var elementKey = this.keyFunction_(element);
ol.DEBUG && console.assert(elementKey in this.queuedElements_,
'key %s is not listed as queued', elementKey);
delete this.queuedElements_[elementKey];
return element;
};

View File

@@ -30,13 +30,6 @@ ol.structs.RBush = function(opt_maxEntries) {
*/
this.items_ = {};
if (ol.DEBUG) {
/**
* @private
* @type {number}
*/
this.readers_ = 0;
}
};
@@ -46,9 +39,6 @@ ol.structs.RBush = function(opt_maxEntries) {
* @param {T} value Value.
*/
ol.structs.RBush.prototype.insert = function(extent, value) {
if (ol.DEBUG && this.readers_) {
throw new Error('Can not insert value while reading');
}
/** @type {ol.RBushEntry} */
var item = {
minX: extent[0],
@@ -59,9 +49,6 @@ ol.structs.RBush.prototype.insert = function(extent, value) {
};
this.rbush_.insert(item);
// remember the object that was added to the internal rbush
ol.DEBUG && console.assert(!(ol.getUid(value) in this.items_),
'uid (%s) of value (%s) already exists', ol.getUid(value), value);
this.items_[ol.getUid(value)] = item;
};
@@ -72,13 +59,6 @@ ol.structs.RBush.prototype.insert = function(extent, value) {
* @param {Array.<T>} values Values.
*/
ol.structs.RBush.prototype.load = function(extents, values) {
if (ol.DEBUG && this.readers_) {
throw new Error('Can not insert values while reading');
}
ol.DEBUG && console.assert(extents.length === values.length,
'extens and values must have same length (%s === %s)',
extents.length, values.length);
var items = new Array(values.length);
for (var i = 0, l = values.length; i < l; i++) {
var extent = extents[i];
@@ -93,8 +73,6 @@ ol.structs.RBush.prototype.load = function(extents, values) {
value: value
};
items[i] = item;
ol.DEBUG && console.assert(!(ol.getUid(value) in this.items_),
'uid (%s) of value (%s) already exists', ol.getUid(value), value);
this.items_[ol.getUid(value)] = item;
}
this.rbush_.load(items);
@@ -107,12 +85,7 @@ ol.structs.RBush.prototype.load = function(extents, values) {
* @return {boolean} Removed.
*/
ol.structs.RBush.prototype.remove = function(value) {
if (ol.DEBUG && this.readers_) {
throw new Error('Can not remove value while reading');
}
var uid = ol.getUid(value);
ol.DEBUG && console.assert(uid in this.items_,
'uid (%s) of value (%s) does not exist', uid, value);
// get the object in which the value was wrapped when adding to the
// internal rbush. then use that object to do the removal.
@@ -128,15 +101,9 @@ ol.structs.RBush.prototype.remove = function(value) {
* @param {T} value Value.
*/
ol.structs.RBush.prototype.update = function(extent, value) {
ol.DEBUG && console.assert(ol.getUid(value) in this.items_,
'uid (%s) of value (%s) does not exist', ol.getUid(value), value);
var item = this.items_[ol.getUid(value)];
var bbox = [item.minX, item.minY, item.maxX, item.maxY];
if (!ol.extent.equals(bbox, extent)) {
if (ol.DEBUG && this.readers_) {
throw new Error('Can not update extent while reading');
}
this.remove(value);
this.insert(extent, value);
}
@@ -185,16 +152,7 @@ ol.structs.RBush.prototype.getInExtent = function(extent) {
* @template S
*/
ol.structs.RBush.prototype.forEach = function(callback, opt_this) {
if (ol.DEBUG) {
++this.readers_;
try {
return this.forEach_(this.getAll(), callback, opt_this);
} finally {
--this.readers_;
}
} else {
return this.forEach_(this.getAll(), callback, opt_this);
}
return this.forEach_(this.getAll(), callback, opt_this);
};
@@ -207,16 +165,7 @@ ol.structs.RBush.prototype.forEach = function(callback, opt_this) {
* @template S
*/
ol.structs.RBush.prototype.forEachInExtent = function(extent, callback, opt_this) {
if (ol.DEBUG) {
++this.readers_;
try {
return this.forEach_(this.getInExtent(extent), callback, opt_this);
} finally {
--this.readers_;
}
} else {
return this.forEach_(this.getInExtent(extent), callback, opt_this);
}
return this.forEach_(this.getInExtent(extent), callback, opt_this);
};