commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1534322 - in /commons/proper/imaging/trunk/src: changes/changes.xml main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
Date Tue, 22 Oct 2013 15:38:43 GMT
On 22 October 2013 05:49, Damjan Jovanovic <damjan@apache.org> wrote:
> On Tue, Oct 22, 2013 at 3:02 AM, sebb <sebbaz@gmail.com> wrote:
>>> +
>>> +    public byte[] getComment() {
>>> +        return comment;
>>
>> This is better, but the array can still be modified externally.
>>
>> Might make more sense to convert the array to a String and return that
>> instead - Strings are immutable, but arrays are not.
>> Otherwise perhaps return a copy.
>>
>
> The text encoding for the JPEG COM segment is unspecified, and can be
> anything in practice, including binary data instead of text, so we
> have to return a byte[].

I suggested returning a String because the only usage I found
immediately converted the bytes into a String.

> I am concerned about the performance implications of copying data
> around so much, but guess it's not much data.

Sometimes it may be necessary to pass around arrays, in which case the
mutability needs to be clearly documented.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message