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

Maruan Sahyoun commented on PDFBOX-5451:
----------------------------------------

IMHO we should try to make COSString immutable (if I'm not mistaken alls other 
primitive COS types are). WRT to the setter if it's too complex to do it now 
(meaning not pushing out 3.0.0 and/or risking a lot of regressions) we should 
mark the setter as internal use only in the docs.

So first step would be to clone the byte array for creation/getting. Maybe the 
title of the ticket should be updated to reflect the immutability if we agree 
on that.

> Avoid copying byte array for COSString
> --------------------------------------
>
>                 Key: PDFBOX-5451
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5451
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: Andreas Lehmkühler
>            Assignee: Andreas Lehmkühler
>            Priority: Major
>             Fix For: 3.0.0 PDFBox
>
>
> When creating a COSString the given byte array is cloned. As in most cases 
> the array is just an intermediate object we should remove that to reduce the 
> memory footprint.
> Furthermore the {{getBytes}} returns the internal byte array so that I don't 
> see any reason not to use the given byte array itself instead of cloning it



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to