diff --git a/src/core/evaluator.js b/src/core/evaluator.js index fb0c075aee499..df604292b43c2 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -3683,7 +3683,7 @@ class TranslatedFont { continue; case OPS.setGState: - const gStateObj = operatorList.argsArray[i]; + const [gStateObj] = operatorList.argsArray[i]; let j = 0, jj = gStateObj.length; while (j < jj) { diff --git a/src/core/function.js b/src/core/function.js index 7f2b8d1da23a2..4dcee828e102b 100644 --- a/src/core/function.js +++ b/src/core/function.js @@ -20,6 +20,7 @@ import { info, isBool, IsEvalSupportedCached, + shadow, unreachable, } from "../shared/util.js"; import { PostScriptLexer, PostScriptParser } from "./ps_parser.js"; @@ -29,7 +30,6 @@ class PDFFunctionFactory { constructor({ xref, isEvalSupported = true }) { this.xref = xref; this.isEvalSupported = isEvalSupported !== false; - this._localFunctionCache = null; // Initialized lazily. } create(fn) { @@ -76,9 +76,6 @@ class PDFFunctionFactory { fnRef = cacheKey.dict && cacheKey.dict.objId; } if (fnRef) { - if (!this._localFunctionCache) { - this._localFunctionCache = new LocalFunctionCache(); - } const localFunction = this._localFunctionCache.getByRef(fnRef); if (localFunction) { return localFunction; @@ -105,12 +102,16 @@ class PDFFunctionFactory { fnRef = cacheKey.dict && cacheKey.dict.objId; } if (fnRef) { - if (!this._localFunctionCache) { - this._localFunctionCache = new LocalFunctionCache(); - } this._localFunctionCache.set(/* name = */ null, fnRef, parsedFunction); } } + + /** + * @private + */ + get _localFunctionCache() { + return shadow(this, "_localFunctionCache", new LocalFunctionCache()); + } } function toNumberArray(arr) {