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:
parent
0d2dd6c2fe
commit
9360c7cbdc
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,10 +328,6 @@ class StructTreePage {
|
||||
}
|
||||
nodeToSerializable(child, root);
|
||||
}
|
||||
|
||||
if (root.children.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
@ -743,15 +743,9 @@ class WorkerMessageHandler {
|
||||
});
|
||||
|
||||
handler.on("GetStructTree", function wphGetStructTree(data) {
|
||||
const pageIndex = data.pageIndex;
|
||||
return pdfManager
|
||||
.getPage(pageIndex)
|
||||
.then(function (page) {
|
||||
return pdfManager.ensure(page, "getStructTree");
|
||||
})
|
||||
.then(function (structTree) {
|
||||
return structTree.serializable;
|
||||
});
|
||||
return pdfManager.getPage(data.pageIndex).then(function (page) {
|
||||
return pdfManager.ensure(page, "getStructTree");
|
||||
});
|
||||
});
|
||||
|
||||
handler.on("FontFallback", function (data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user