diff --git a/src/ol/render/canvas/textreplay.js b/src/ol/render/canvas/textreplay.js index 9417e1c40e..70449d1c76 100644 --- a/src/ol/render/canvas/textreplay.js +++ b/src/ol/render/canvas/textreplay.js @@ -129,6 +129,9 @@ ol.render.canvas.TextReplay = function( */ this.widths_ = {}; + var labelCache = ol.render.canvas.labelCache; + labelCache.prune(); + }; ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay); @@ -301,7 +304,7 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey Math.ceil(renderWidth * scale), Math.ceil((height + strokeWidth) * scale)); label = context.canvas; - labelCache.pruneAndSet(key, label); + labelCache.set(key, label); if (scale != 1) { context.scale(scale, scale); } diff --git a/src/ol/structs/lrucache.js b/src/ol/structs/lrucache.js index 2743854de6..d86533bc5c 100644 --- a/src/ol/structs/lrucache.js +++ b/src/ol/structs/lrucache.js @@ -268,12 +268,10 @@ ol.structs.LRUCache.prototype.set = function(key, value) { /** - * @param {string} key Key. - * @param {T} value Value. + * Prune the cache. */ -ol.structs.LRUCache.prototype.pruneAndSet = function(key, value) { +ol.structs.LRUCache.prototype.prune = function() { while (this.canExpireCache()) { this.pop(); } - this.set(key, value); };