Merge pull request #7514 from ahocevar/less-aggressive-prune
Prune the label cache less aggressively
This commit is contained in:
@@ -129,6 +129,9 @@ ol.render.canvas.TextReplay = function(
|
|||||||
*/
|
*/
|
||||||
this.widths_ = {};
|
this.widths_ = {};
|
||||||
|
|
||||||
|
var labelCache = ol.render.canvas.labelCache;
|
||||||
|
labelCache.prune();
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);
|
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(renderWidth * scale),
|
||||||
Math.ceil((height + strokeWidth) * scale));
|
Math.ceil((height + strokeWidth) * scale));
|
||||||
label = context.canvas;
|
label = context.canvas;
|
||||||
labelCache.pruneAndSet(key, label);
|
labelCache.set(key, label);
|
||||||
if (scale != 1) {
|
if (scale != 1) {
|
||||||
context.scale(scale, scale);
|
context.scale(scale, scale);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,12 +268,10 @@ ol.structs.LRUCache.prototype.set = function(key, value) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key Key.
|
* Prune the cache.
|
||||||
* @param {T} value Value.
|
|
||||||
*/
|
*/
|
||||||
ol.structs.LRUCache.prototype.pruneAndSet = function(key, value) {
|
ol.structs.LRUCache.prototype.prune = function() {
|
||||||
while (this.canExpireCache()) {
|
while (this.canExpireCache()) {
|
||||||
this.pop();
|
this.pop();
|
||||||
}
|
}
|
||||||
this.set(key, value);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user