Optimize tile dropping in reprioritize

This commit is contained in:
Tom Payne
2013-01-19 15:24:50 +01:00
parent a8dc810696
commit 4b971b5f32

View File

@@ -250,9 +250,8 @@ ol.TileQueue.prototype.siftDown_ = function(startIndex, index) {
*/ */
ol.TileQueue.prototype.reprioritize = function() { ol.TileQueue.prototype.reprioritize = function() {
var heap = this.heap_; var heap = this.heap_;
var count = heap.length; var i, n = 0, node, priority, tile, tileCenter, tileSourceKey;
var i, priority, node, tile, tileCenter, tileSourceKey; for (i = 0; i < heap.length; ++i) {
for (i = count - 1; i >= 0; i--) {
node = heap[i]; node = heap[i];
tile = /** @type {ol.Tile} */ (node[1]); tile = /** @type {ol.Tile} */ (node[1]);
tileSourceKey = /** @type {string} */ (node[2]); tileSourceKey = /** @type {string} */ (node[2]);
@@ -260,9 +259,9 @@ ol.TileQueue.prototype.reprioritize = function() {
priority = this.tilePriorityFunction_(tile, tileSourceKey, tileCenter); priority = this.tilePriorityFunction_(tile, tileSourceKey, tileCenter);
if (priority != ol.TileQueue.DROP) { if (priority != ol.TileQueue.DROP) {
node[0] = priority; node[0] = priority;
} else { heap[n++] = node;
goog.array.removeAt(heap, i);
} }
} }
heap.length = n;
this.heapify_(); this.heapify_();
}; };