mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Re-factor the arraysToBytes
helper function (PR 16032 follow-up)
Currently this helper function only has two call-sites, and both of them only pass in `ArrayBuffer` data. Given how it's implemented there's a couple of code-paths that are completely unused (e.g. the "string" one), and in particular the intended fast-paths don't actually work. This patch re-factors and simplifies the helper function, and it'll no longer accept anything except `ArrayBuffer` data (hence why it's also re-named). Note that at the time when `arraysToBytes` was added we still supported browsers without TypedArray functionality, and we'd then simulate them using regular Arrays.
This commit is contained in:
parent
5ba596786c
commit
c56f25409d
3 changed files with 34 additions and 46 deletions
|
@ -15,7 +15,7 @@
|
|||
|
||||
import {
|
||||
AbortException,
|
||||
arraysToBytes,
|
||||
arrayBuffersToBytes,
|
||||
assert,
|
||||
createPromiseCapability,
|
||||
getVerbosityLevel,
|
||||
|
@ -281,7 +281,7 @@ class WorkerMessageHandler {
|
|||
|
||||
let loaded = 0;
|
||||
const flushChunks = function () {
|
||||
const pdfFile = arraysToBytes(cachedChunks);
|
||||
const pdfFile = arrayBuffersToBytes(cachedChunks);
|
||||
if (length && pdfFile.length !== length) {
|
||||
warn("reported HTTP length is different from actual");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue