Skip to content

Commit a5a27a5

Browse files
Merge pull request #20705 from Snuffleupagus/#collectParents-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectParents` method
2 parents 8189ca3 + 3e7ad8d commit a5a27a5

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

src/core/struct_tree.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,7 @@ class StructTreeRoot {
450450
for (const element of elements) {
451451
if (element.structTreeParentId) {
452452
const id = parseInt(element.structTreeParentId.split("_mc")[1], 10);
453-
let elems = idToElements.get(id);
454-
if (!elems) {
455-
elems = [];
456-
idToElements.set(id, elems);
457-
}
458-
elems.push(element);
453+
idToElements.getOrInsert(id, []).push(element);
459454
}
460455
}
461456

0 commit comments

Comments
 (0)