From 4b971b5f32d85af40b75039e8285ffd19d7242f8 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sat, 19 Jan 2013 15:24:50 +0100 Subject: [PATCH] Optimize tile dropping in reprioritize --- src/ol/tilequeue.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ol/tilequeue.js b/src/ol/tilequeue.js index 1df40e0f01..8a599d5439 100644 --- a/src/ol/tilequeue.js +++ b/src/ol/tilequeue.js @@ -250,9 +250,8 @@ ol.TileQueue.prototype.siftDown_ = function(startIndex, index) { */ ol.TileQueue.prototype.reprioritize = function() { var heap = this.heap_; - var count = heap.length; - var i, priority, node, tile, tileCenter, tileSourceKey; - for (i = count - 1; i >= 0; i--) { + var i, n = 0, node, priority, tile, tileCenter, tileSourceKey; + for (i = 0; i < heap.length; ++i) { node = heap[i]; tile = /** @type {ol.Tile} */ (node[1]); tileSourceKey = /** @type {string} */ (node[2]); @@ -260,9 +259,9 @@ ol.TileQueue.prototype.reprioritize = function() { priority = this.tilePriorityFunction_(tile, tileSourceKey, tileCenter); if (priority != ol.TileQueue.DROP) { node[0] = priority; - } else { - goog.array.removeAt(heap, i); + heap[n++] = node; } } + heap.length = n; this.heapify_(); };