Use getOrInsertComputed in the CanvasGraphics.prototype._getPattern method

This commit is contained in:
Jonas Jenwald 2026-07-17 12:49:29 +02:00
parent dd7e3731d1
commit 0f060e1e64

View File

@ -3092,13 +3092,9 @@ class CanvasGraphics {
}
_getPattern(opIdx, objId, matrix = null) {
let pattern;
if (this.cachedPatterns.has(objId)) {
pattern = this.cachedPatterns.get(objId);
} else {
pattern = getShadingPattern(this.getObject(opIdx, objId));
this.cachedPatterns.set(objId, pattern);
}
const pattern = this.cachedPatterns.getOrInsertComputed(objId, () =>
getShadingPattern(this.getObject(opIdx, objId))
);
if (matrix) {
pattern.matrix = matrix;
}