mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-08 08:05:49 +02:00
Use Map.prototype.getOrInsert() in the #collectParents method
This commit is contained in:
parent
f548a159d6
commit
3e7ad8d6bf
@ -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