From cc749a79675cb9da1654dd45a270a1eef27acafe Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 31 Jan 2012 11:55:19 +0100 Subject: [PATCH] Don't queue tiles multiple times. This results in a smaller queue that we don't have to unqueue from. --- lib/OpenLayers/Layer/Grid.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index f4cc52ba38..fa17b5b023 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -414,7 +414,11 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * evt - {Object} Listener argument of the tile's beforedraw event */ queueTileDraw: function(evt) { - this.tileQueue.push(evt.object); + var tile = evt.object; + if (!~OpenLayers.Util.indexOf(this.tileQueue, tile)) { + // queue only if not in queue already + this.tileQueue.push(tile); + } if (!this.tileQueueId) { this.tileQueueId = OpenLayers.Animation.start( OpenLayers.Function.bind(this.drawTileFromQueue, this), @@ -433,26 +437,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { this.clearTileQueue(); } else { var tile = this.tileQueue.shift(); - this.unqueueTile(tile); tile.draw(true); } }, - /** - * Method: unqueueTile - * Removes all occurrences of a tile from the . - * - * Parameters: - * tile - {} The tile to remove from the queue - */ - unqueueTile: function(tile) { - for (var i=this.tileQueue.length-1; i>=0; --i) { - if (this.tileQueue[i] === tile) { - this.tileQueue.splice(i, 1); - } - } - }, - /** * Method: clearTileQueue * Clears the animation queue @@ -470,7 +458,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * tile - {} */ destroyTile: function(tile) { - this.unqueueTile(tile); this.removeTileMonitoringHooks(tile); tile.destroy(); },