[PATCH] optimization opportunity regarding misuse of BufferedInputStream
Florian Weimer
fweimer at redhat.com
Fri Aug 28 10:08:03 UTC 2020
* Сергей Цыпанов:
> @@ -105,12 +105,8 @@
> private byte[] getBytes(InputStream is)
> throws IOException
> {
> - byte[] buffer = new byte[8192];
> ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
> - int n;
> - while ((n = is.read(buffer, 0, buffer.length)) != -1) {
> - baos.write(buffer, 0, n);
> - }
> + is.transferTo(baos);
> return baos.toByteArray();
> }
Isn't this InputStream::readAllBytes?
Thanks,
Florian
More information about the core-libs-dev
mailing list