<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div dir="ltr">Thanks for the good suggestion Pavel - will look into that - for large arrays absolutely less costly than copying!<div><br></div><div>In the general case I would still prefer if the libraries generally provided offset & length for byte array arguments to allow for "garbage free" code (i.e. avoiding to frequently create various wrapper objects like ByteBuffer from heap memory). </div><div><br></div><div>Best Regards</div><div>Trist</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 14, 2023 at 8:57 PM Pavel Rappo <<a href="mailto:pavel.rappo@oracle.com">pavel.rappo@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
> On 14 Dec 2023, at 06:10, Magnus <<a href="mailto:magnus.eriksson@gmail.com" target="_blank">magnus.eriksson@gmail.com</a>> wrote:<br>
> <br>
> In the java libraries there are many methods that operate on byte arrays that do not allow you to specify offset and length for the relevant data instead forcing you to copy the relevant part to new arrays before using the methods reducing performance - I am for instance struggling with this in java.util.Base64 where the Encoders and Decoders lack a length parameter (also an offset would have been great even though I don't need that in my case). <br>
<br>
Re: java.util.Base64. Encoder and Decoder also seem to be able to work with ByteBuffer. If you have an array, you can cheaply create a ByteBuffer wrapper around that array. The now-backing array would be read or written though from the specific position and up to the specific limit. Would that help?<br>
<br>
-Pavel<br>
<br>
</blockquote></div></div>