Merge pull request #20705 from Snuffleupagus/#collectParents-getOrInsert

Use `Map.prototype.getOrInsert()` in the `#collectParents` method
This commit is contained in:
Tim van der Meij 2026-02-22 12:55:41 +01:00 committed by GitHub
commit a5a27a5ca7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -450,12 +450,7 @@ class StructTreeRoot {
for (const element of elements) {
if (element.structTreeParentId) {
const id = parseInt(element.structTreeParentId.split("_mc")[1], 10);
let elems = idToElements.get(id);
if (!elems) {
elems = [];
idToElements.set(id, elems);
}
elems.push(element);
idToElements.getOrInsert(id, []).push(element);
}
}