mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-09 23:04:02 +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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user