mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
[api-minor] Simplify how the list of points are structured
Instead of sending to the main thread an array of Objects for a list of points (or quadpoints), we'll send just a basic float buffer. It should slightly improve performances (especially when cloning the data) and use slightly less memory.
This commit is contained in:
parent
24e12d515d
commit
6fa98ac99f
5 changed files with 162 additions and 202 deletions
|
@ -303,7 +303,20 @@ async function getSerialized(page, filter = undefined) {
|
|||
const values = await page.evaluate(() => {
|
||||
const { map } =
|
||||
window.PDFViewerApplication.pdfDocument.annotationStorage.serializable;
|
||||
return map ? [...map.values()] : [];
|
||||
if (!map) {
|
||||
return [];
|
||||
}
|
||||
const vals = Array.from(map.values());
|
||||
for (const value of vals) {
|
||||
for (const [k, v] of Object.entries(value)) {
|
||||
// Puppeteer don't serialize typed array correctly, so we convert them
|
||||
// to arrays.
|
||||
if (ArrayBuffer.isView(v)) {
|
||||
value[k] = Array.from(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
return vals;
|
||||
});
|
||||
return filter ? values.map(filter) : values;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue