Skip to content

Commit

Permalink
Merge pull request #17166 from calixteman/improve_oc_parsing
Browse files Browse the repository at this point in the history
Improve performance of optional content parsing
  • Loading branch information
calixteman authored Oct 25, 2023
2 parents 806ac67 + 0c38c6e commit b31e77d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,14 @@ class Catalog {
return shadow(this, "optionalContentConfig", null);
}
const groups = [];
const groupRefs = [];
const groupRefs = new RefSet();
// Ensure all the optional content groups are valid.
for (const groupRef of groupsData) {
if (!(groupRef instanceof Ref)) {
if (!(groupRef instanceof Ref) || groupRefs.has(groupRef)) {
continue;
}
groupRefs.push(groupRef);
const group = this.xref.fetchIfRef(groupRef);
groupRefs.put(groupRef);
const group = this.xref.fetch(groupRef);
groups.push({
id: groupRef.toString(),
name:
Expand Down Expand Up @@ -477,7 +477,7 @@ class Catalog {
if (!(value instanceof Ref)) {
continue;
}
if (contentGroupRefs.includes(value)) {
if (contentGroupRefs.has(value)) {
onParsed.push(value.toString());
}
}
Expand All @@ -492,7 +492,7 @@ class Catalog {
const order = [];

for (const value of refs) {
if (value instanceof Ref && contentGroupRefs.includes(value)) {
if (value instanceof Ref && contentGroupRefs.has(value)) {
parsedOrderRefs.put(value); // Handle "hidden" groups, see below.

order.push(value.toString());
Expand Down

0 comments on commit b31e77d

Please sign in to comment.