Gap Buffer based AbstractStringBuilder implementation
Ulf Zibis
Ulf.Zibis at gmx.de
Fri Nov 20 18:48:19 UTC 2009
Am 20.11.2009 18:30, Osvaldo Doederlein schrieb:
> Hi Goktug,
>
> The same problem happens in other buffer-like APIs. In one project I
> had to re-implement ByteArrayOutputStream, copying the source code
> from the JDK but just adding a method that returns the internal array,
> because I was using it for moderately large buffers, doing this
> several dozens of times per second, and the cost of copying data was
> significant. It's worth notice that in some cases when I can predict
> exactly the size of the buffer, I can use that trick even if I don't
> want any extra bytes in the resulting array.
Also having java.nio.ByteBuffer#clear(byte[]), ...#reset(byte[]) would
allow to fill existing Buffer with new data, without having to always
instantiate new object by ByteBuffer.wrap(byte[]).
-Ulf
More information about the core-libs-dev
mailing list