On Thu, 21 Jul 2022 15:37:40 GMT, Сергей Цыпанов <d...@openjdk.org> wrote:

> We can use `InputStream.readAllBytes()` in `ModuleHashes` and `X509CertPath`.

If by “surrogates” you mean “substitutes”, then this wording is confusing. At 
the time these explicit loops were written they weren’t surrogates for 
anything, since `InputStream::readAllBytes` didn’t yet exist. Please revise the 
summary to say “... instead of explicit loops”.

I share @wangweij’s concern about the change to the `ModuleHashes` class. The 
original code does not read the entirety of each stream into a single byte 
array because it doesn’t need to in order to update the digest. Furthermore, it 
re-uses the same byte array for all of the (potentially many) input streams. 
Your change would allocate a new byte array for each input stream, which seems 
likely to be slower. Please measure this (using, e.g., [JMH]) before making 
such a change.

[JMH]: https://github.com/openjdk/jmh

-------------

PR: https://git.openjdk.org/jdk/pull/9596

Reply via email to