Merge pull request #20716 from Snuffleupagus/src-display-getOrInsert

Use `Map.prototype.getOrInsert()` more in the `src/display/` folder
This commit is contained in:
Jonas Jenwald 2026-02-22 21:00:38 +01:00 committed by GitHub
commit 7b451f6a89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 11 deletions

View File

@ -3877,12 +3877,7 @@ class AnnotationLayer {
this.#elements.push(element);
if (data.popupRef) {
const elements = popupToElements.get(data.popupRef);
if (!elements) {
popupToElements.set(data.popupRef, [element]);
} else {
elements.push(element);
}
popupToElements.getOrInsert(data.popupRef, []).push(element);
}
}

View File

@ -989,11 +989,10 @@ class CanvasGraphics {
: [currentTransform.slice(0, 4), fillColor]
);
cache = this._cachedBitmapsMap.get(mainKey);
if (!cache) {
cache = new Map();
this._cachedBitmapsMap.set(mainKey, cache);
}
cache = this._cachedBitmapsMap.getOrInsertComputed(
mainKey,
() => new Map()
);
const cachedImage = cache.get(cacheKey);
if (cachedImage && !isPatternFill) {
const offsetX = Math.round(