[
https://issues.apache.org/jira/browse/PDFBOX-5996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17947760#comment-17947760
]
ASF subversion and git services commented on PDFBOX-5996:
---------------------------------------------------------
Commit 1925302 from Tilman Hausherr in branch 'pdfbox/branches/3.0'
[ https://svn.apache.org/r1925302 ]
PDFBOX-5996: Set size for ByteArrayOutputStreams, as suggested by Axel Howind
> set size for ByteArrayOutputStreams
> -----------------------------------
>
> Key: PDFBOX-5996
> URL: https://issues.apache.org/jira/browse/PDFBOX-5996
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 2.0.34, 3.0.4 PDFBox
> Reporter: Axel Howind
> Priority: Minor
> Attachments:
> set_initial_sizes_for_ByteArrayOutputStreams_set_initial_sizes_for_ByteArrayOutputStreams.patch
>
>
> 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]