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) { _getPattern(opIdx, objId, matrix = null) {
let pattern; const pattern = this.cachedPatterns.getOrInsertComputed(objId, () =>
if (this.cachedPatterns.has(objId)) { getShadingPattern(this.getObject(opIdx, objId))
pattern = this.cachedPatterns.get(objId); );
} else {
pattern = getShadingPattern(this.getObject(opIdx, objId));
this.cachedPatterns.set(objId, pattern);
}
if (matrix) { if (matrix) {
pattern.matrix = matrix; pattern.matrix = matrix;
} }