Only schedule the icon cache expire when it's needed

This commit is contained in:
Frederic Junod
2018-12-19 14:25:02 +01:00
parent a4fe067aad
commit 3193de0906
3 changed files with 12 additions and 3 deletions
+8 -1
View File
@@ -37,11 +37,18 @@ class IconImageCache {
this.cacheSize_ = 0;
}
/**
* @return {boolean} Can expire cache.
*/
canExpireCache() {
return this.cacheSize_ > this.maxCacheSize_;
}
/**
* FIXME empty description for jsdoc
*/
expire() {
if (this.cacheSize_ > this.maxCacheSize_) {
if (this.canExpireCache()) {
let i = 0;
for (const key in this.cache_) {
const iconImage = this.cache_[key];