mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-29 18:37:20 +02:00
Merge pull request #20705 from Snuffleupagus/#collectParents-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectParents` method
This commit is contained in:
commit
a5a27a5ca7
@ -450,12 +450,7 @@ class StructTreeRoot {
|
|||||||
for (const element of elements) {
|
for (const element of elements) {
|
||||||
if (element.structTreeParentId) {
|
if (element.structTreeParentId) {
|
||||||
const id = parseInt(element.structTreeParentId.split("_mc")[1], 10);
|
const id = parseInt(element.structTreeParentId.split("_mc")[1], 10);
|
||||||
let elems = idToElements.get(id);
|
idToElements.getOrInsert(id, []).push(element);
|
||||||
if (!elems) {
|
|
||||||
elems = [];
|
|
||||||
idToElements.set(id, elems);
|
|
||||||
}
|
|
||||||
elems.push(element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user