1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Avoid unnecessary parsing, in Page.GetStructTree, when no structTree is available (PR 13221 follow-up)

It's obviously (a bit) more efficient to return early in `Page.getStructTree`, rather than trying to first "parse" an *empty* structTree-root.

*Somehow I didn't think of this yesterday, but this feels like a much better solution overall; sorry about the churn here!*
This commit is contained in:
Jonas Jenwald 2021-04-12 08:52:35 +02:00
parent 0d2dd6c2fe
commit 9360c7cbdc
3 changed files with 10 additions and 14 deletions

View file

@ -454,7 +454,13 @@ class Page {
const structTreeRoot = await this.pdfManager.ensureCatalog(
"structTreeRoot"
);
return this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
if (!structTreeRoot) {
return null;
}
const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [
structTreeRoot,
]);
return structTree.serializable;
}
/**