Axel Howind created PDFBOX-5996:
-----------------------------------
Summary: set size for ByteArrayOutputStreams
Key: PDFBOX-5996
URL: https://issues.apache.org/jira/browse/PDFBOX-5996
Project: PDFBox
Issue Type: Improvement
Reporter: Axel Howind
PDFBox and FontBox use ByteArrayOutputstream instances in many places. The
standard JDK implementation initializes the size with 32 bytes. If the capacity
needs to be increased, the increases the buffer size, usually by reallocating a
buffer twice the current size and copying the internal array to the new buffer.
I have checked different places in the code and found many instances where
either the correct size is known beforehand and can be set when creating the
instance (this is the case for many instantiations in the PDFFont and COSString
classes). Setting the exact size avoids reallocations when the used size will
exceed the default size of 32 bytes.
In other places, at least a lower bound is known and can be used as initial
size.
Please try the patches. I did not run benchmarks, but (together with another
patch I am preparing) the times to run the test target decreased noticeably on
my machine.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]