Remove unnecessary duplication in the addChildren
helper function (used by the ObjectLoader
)
Besides being fewer lines of code overall, this also avoids *one* `node instanceof Dict` check for both of the `Dict`/`Stream`-cases.
This commit is contained in:
parent
ea8e432c45
commit
684a7b89ac
@ -2205,18 +2205,16 @@ const ObjectLoader = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addChildren(node, nodesToVisit) {
|
function addChildren(node, nodesToVisit) {
|
||||||
if (node instanceof Dict || isStream(node)) {
|
if (node instanceof Dict) {
|
||||||
const dict = node instanceof Dict ? node : node.dict;
|
node = node.getRawValues();
|
||||||
for (const rawValue of dict.getRawValues()) {
|
} else if (isStream(node)) {
|
||||||
if (mayHaveChildren(rawValue)) {
|
node = node.dict.getRawValues();
|
||||||
nodesToVisit.push(rawValue);
|
} else if (!Array.isArray(node)) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
} else if (Array.isArray(node)) {
|
for (const rawValue of node) {
|
||||||
for (const value of node) {
|
if (mayHaveChildren(rawValue)) {
|
||||||
if (mayHaveChildren(value)) {
|
nodesToVisit.push(rawValue);
|
||||||
nodesToVisit.push(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user