Merge pull request #21590 from Snuffleupagus/canvas-_getPattern-getOrInsertComputed

Use `getOrInsertComputed` in the `CanvasGraphics.prototype._getPattern` method
This commit is contained in:
Tim van der Meij 2026-07-19 13:45:56 +02:00 committed by GitHub
commit e624336b2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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;
}