From 7b9fc4c995e264a50f728d4ee8eafa596f26fb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Tue, 28 Jun 2022 16:37:03 +0200 Subject: [PATCH] Do not refresh use time for tiles when collecting used source tiles --- src/ol/source/VectorTile.js | 5 +++-- src/ol/structs/LRUCache.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 608eda5674..72f64ccdf1 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -240,8 +240,9 @@ class VectorTile extends UrlTile { const tileCache = this.getTileCacheForProjection(projection); const usedSourceTiles = Object.keys(usedTiles).reduce((acc, key) => { const cacheKey = getCacheKeyForTileKey(key); - if (tileCache.containsKey(cacheKey)) { - const sourceTiles = tileCache.get(cacheKey).sourceTiles; + const tile = tileCache.peek(cacheKey); + if (tile) { + const sourceTiles = tile.sourceTiles; for (let i = 0, ii = sourceTiles.length; i < ii; ++i) { acc[sourceTiles[i].getKey()] = true; } diff --git a/src/ol/structs/LRUCache.js b/src/ol/structs/LRUCache.js index f8c7e01385..2db45384ec 100644 --- a/src/ol/structs/LRUCache.js +++ b/src/ol/structs/LRUCache.js @@ -214,6 +214,18 @@ class LRUCache { return this.newest_.key_; } + /** + * Return an entry without updating least recently used time. + * @param {string} key Key. + * @return {T} Value. + */ + peek(key) { + if (!this.containsKey(key)) { + return undefined; + } + return this.entries_[key].value_; + } + /** * @return {T} value Value. */