mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Reduce duplication when collecting optional content groups
After PR 18825 we can easily "compute" the optional content groups, and can thus avoid tracking them manually.
This commit is contained in:
parent
424f81c4db
commit
805f962181
1 changed files with 2 additions and 7 deletions
|
@ -485,19 +485,15 @@ class Catalog {
|
|||
if (!Array.isArray(groupsData)) {
|
||||
return shadow(this, "optionalContentConfig", null);
|
||||
}
|
||||
const groups = [];
|
||||
const groupRefCache = new RefSetCache();
|
||||
// Ensure all the optional content groups are valid.
|
||||
for (const groupRef of groupsData) {
|
||||
if (!(groupRef instanceof Ref) || groupRefCache.has(groupRef)) {
|
||||
continue;
|
||||
}
|
||||
const group = this.#readOptionalContentGroup(groupRef);
|
||||
groups.push(group);
|
||||
groupRefCache.put(groupRef, group);
|
||||
groupRefCache.put(groupRef, this.#readOptionalContentGroup(groupRef));
|
||||
}
|
||||
config = this.#readOptionalContentConfig(defaultConfig, groupRefCache);
|
||||
config.groups = groups;
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
|
@ -649,7 +645,6 @@ class Catalog {
|
|||
if (!Array.isArray(rbGroup) || !rbGroup.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const parsedRbGroup = new Set();
|
||||
|
||||
for (const ref of rbGroup) {
|
||||
|
@ -688,7 +683,7 @@ class Catalog {
|
|||
on: parseOnOff(config.get("ON")),
|
||||
off: parseOnOff(config.get("OFF")),
|
||||
order: parseOrder(config.get("Order")),
|
||||
groups: null,
|
||||
groups: [...groupRefCache],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue