[ 
https://issues.apache.org/jira/browse/PDFBOX-5999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949269#comment-17949269
 ] 

ASF subversion and git services commented on PDFBOX-5999:
---------------------------------------------------------

Commit 1925395 from le...@apache.org in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1925395 ]

PDFBOX-5999: fix initial ByteArrayOutputStream size as proposed by Axel Howind

> fix initial ByteArrayOutputStream size for deflate operation
> ------------------------------------------------------------
>
>                 Key: PDFBOX-5999
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5999
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.34, 3.0.5 PDFBox, 4.0.0
>            Reporter: Axel Howind
>            Assignee: Andreas Lehmkühler
>            Priority: Minor
>             Fix For: 2.0.35, 3.0.6 PDFBox, 4.0.0
>
>         Attachments: fix_initial_ByteArrayOutputStream_size.patch
>
>
> When I re-checked my last patch about initializing ByteArrayOutputStream 
> instances with the matching size, I saw that I confused the deflate and 
> inflate operations. Here the resulting array can be expected less in size 
> than the original array:
> ```
>         ByteArrayOutputStream deflated = new 
> ByteArrayOutputStream(Math.max(32, data.length / 2));
> ```
> The patch fixes this and allocates half the size of the deflater input. This 
> should be a good enough estimate in most cases.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to