From f8ad0acfa474ca76afb23b4de78ade610c0b42d2 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 2 Aug 2023 21:04:43 +0200 Subject: [PATCH] Sort the N tiles only once instead of when adding new indiviual tiles --- src/tiledimage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 0bedb701..869d3633 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1437,6 +1437,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag } } + this._sortTiles(best); return best; }, @@ -1930,8 +1931,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag return [tile]; } previousBest.push(tile); - this._sortTiles(previousBest); if (previousBest.length > maxNTiles) { + this._sortTiles(previousBest); previousBest.pop(); } return previousBest;