Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the PDFFunctionFactory._localFunctionCache initialization (PR 12034 follow-up); Fix the gStateObj lookup in TranslatedFont._removeType3ColorOperators (PR 12718 follow-up) #12885

Merged
merged 2 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 8 additions & 7 deletions src/core/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
info,
isBool,
IsEvalSupportedCached,
shadow,
unreachable,
} from "../shared/util.js";
import { PostScriptLexer, PostScriptParser } from "./ps_parser.js";
Expand All @@ -29,7 +30,6 @@ class PDFFunctionFactory {
constructor({ xref, isEvalSupported = true }) {
this.xref = xref;
this.isEvalSupported = isEvalSupported !== false;
this._localFunctionCache = null; // Initialized lazily.
}

create(fn) {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down