pdf.js/src
Jonas Jenwald 32bfa55d98 Attempt to estimate the minimum required buffer length when initializing StreamsSequenceStream instances
For most other `DecodeStream` based streams, we'll attempt to estimate the minimum `buffer` length based on the raw stream data. The purpose of this is to avoid having to unnecessarily re-size the `buffer`, thus reducing the number of *intermediate* allocations necessary when decoding the stream data.
However, currently no such optimization is attempted for `StreamsSequenceStream`, and given that they can often be quite large that seems unfortunate. To improve this, at least somewhat, this patch utilizes the raw sizes of the `StreamsSequenceStream` sub-streams to estimate the minimum required `buffer` length.

Most likely this patch won't have a huge effect on memory consumption, however for pathological cases it should help reduce peak memory usage slightly.
One example is the PDF file in issue 2813, where currently the `StreamsSequenceStream` instances would grow their `buffer`s as `2 MiB -> 4 MiB -> 8 MiB -> 16 MiB -> 32 MiB`. With this patch, the same stream `buffers`s grow as `8 MiB -> 16 MiB -> 32 MiB`, thus avoiding a total of `12 MiB` of *intermediate* allocations (since there's two `StreamsSequenceStream` used, for rendering/text-extraction).
2018-07-26 13:42:59 +02:00
..
core Attempt to estimate the minimum required buffer length when initializing StreamsSequenceStream instances 2018-07-26 13:42:59 +02:00
display Prevent Metadata/XML parsing from breaking PDFDocumentProxy.getMetadata when no XML root document is found (issue 8884) 2018-07-18 11:37:40 +02:00
images Vectorize the logo. 2012-10-29 14:08:52 -04:00
shared Move the toRoman helper function out of the Util scope 2018-07-10 10:45:25 +02:00
doc_helper.js [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
license_header_libre.js PDFjs now compatible with Librejs 2017-12-19 15:13:50 +05:30
license_header.js Replace copyright headers; changes UMD to CommonJS. 2017-02-08 16:35:58 -06:00
pdf.image_decoders.js Add a gulp image_decoders command to allow packaging/distributing the image decoders (i.e. jpg.js, jpx.js, jbig2.js) separately from the main PDF.js library 2018-06-16 17:56:54 +02:00
pdf.js Stop exposing the URL polyfill in the global scope 2018-07-04 09:16:28 +02:00
pdf.worker.entry.js Rename the globals to shorter names. 2018-03-16 11:08:56 -07:00
pdf.worker.js Adds Streams API support for networking task of PDF.js project. 2017-07-28 02:32:30 +05:30
worker_loader.js Moves global scope out of shared/util. 2017-08-22 18:20:52 -05:00