Merge pull request #18905 from Snuffleupagus/optionalContentConfig-determine-groups
Reduce duplication when collecting optional content groups
This commit is contained in:
commit
ec79316379
@ -485,19 +485,15 @@ class Catalog {
|
|||||||
if (!Array.isArray(groupsData)) {
|
if (!Array.isArray(groupsData)) {
|
||||||
return shadow(this, "optionalContentConfig", null);
|
return shadow(this, "optionalContentConfig", null);
|
||||||
}
|
}
|
||||||
const groups = [];
|
|
||||||
const groupRefCache = new RefSetCache();
|
const groupRefCache = new RefSetCache();
|
||||||
// Ensure all the optional content groups are valid.
|
// Ensure all the optional content groups are valid.
|
||||||
for (const groupRef of groupsData) {
|
for (const groupRef of groupsData) {
|
||||||
if (!(groupRef instanceof Ref) || groupRefCache.has(groupRef)) {
|
if (!(groupRef instanceof Ref) || groupRefCache.has(groupRef)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const group = this.#readOptionalContentGroup(groupRef);
|
groupRefCache.put(groupRef, this.#readOptionalContentGroup(groupRef));
|
||||||
groups.push(group);
|
|
||||||
groupRefCache.put(groupRef, group);
|
|
||||||
}
|
}
|
||||||
config = this.#readOptionalContentConfig(defaultConfig, groupRefCache);
|
config = this.#readOptionalContentConfig(defaultConfig, groupRefCache);
|
||||||
config.groups = groups;
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (ex instanceof MissingDataException) {
|
if (ex instanceof MissingDataException) {
|
||||||
throw ex;
|
throw ex;
|
||||||
@ -649,7 +645,6 @@ class Catalog {
|
|||||||
if (!Array.isArray(rbGroup) || !rbGroup.length) {
|
if (!Array.isArray(rbGroup) || !rbGroup.length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedRbGroup = new Set();
|
const parsedRbGroup = new Set();
|
||||||
|
|
||||||
for (const ref of rbGroup) {
|
for (const ref of rbGroup) {
|
||||||
@ -688,7 +683,7 @@ class Catalog {
|
|||||||
on: parseOnOff(config.get("ON")),
|
on: parseOnOff(config.get("ON")),
|
||||||
off: parseOnOff(config.get("OFF")),
|
off: parseOnOff(config.get("OFF")),
|
||||||
order: parseOrder(config.get("Order")),
|
order: parseOrder(config.get("Order")),
|
||||||
groups: null,
|
groups: [...groupRefCache],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user