commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne (JIRA)" <>
Subject [jira] Resolved: (IO-97) Trivial performance improvements to ByteArrayOutputStream
Date Fri, 29 Dec 2006 13:51:25 GMT
     [ ]

Stephen Colebourne resolved IO-97.

    Fix Version/s: 1.3
                       (was: 1.4)
       Resolution: Fixed
         Assignee: Stephen Colebourne

> Trivial performance improvements to ByteArrayOutputStream
> ---------------------------------------------------------
>                 Key: IO-97
>                 URL:
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Streams/Writers
>    Affects Versions: 1.2
>            Reporter: Holger Hoffstätte
>         Assigned To: Stephen Colebourne
>             Fix For: 1.3
>         Attachments: BAOS.patch
> Found a few trivial ways to improve performance in ByteArrayOutputStream by fast paths:
> - write(int) does not have to be synchronized
> - write(byte[]..) does not have to be synchronized as a whole either; it's enough to
synchonize the code that follows the first paramter-checking if-then statement (so parameter
checks can pop out quickly)
> - toByteArray() could just check if count == 0 and quickly return an empty static final
byte[] instead of returning a new zero-sized one, doing useless System.arraycopy() etc.
> A somewhat more involved optimization would be to implement write(int) without the new
byte[1] since just poking the byte into the right page is going to be much faster than what
happens in write(byte[]..); I'll see if I can do a patch for that.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message