On Fri, 14 Jun 2024 09:47:31 GMT, Ferenc Rakoczi <d...@openjdk.org> wrote:
>> src/java.base/share/classes/sun/security/provider/SHA3.java line 73: >> >>> 71: // The following array is allocated to size WIDTH bytes, but we only >>> 72: // ever use the first blockSize bytes it (for bytes <-> long >>> conversions) >>> 73: private byte[] byteState = new byte[WIDTH]; >> >> Since we are storing the state in longs now, this "byte <-> long" conversion >> can be made through a local variable, right? Is there a reason for having >> this `byteState` field with size WIDTH bytes? > > This is interesting: if I use WIDTH (or in blockSize) long arrays in the > local level, the performance drops a few per cents. Even more when I only > declare the local array in the block in which it is used. However, since we > really only need 8 bytes, if I allocate that at the beginning of the > function, I don't see that performance drop. So I rewrote the output loop in > the function and got rid of the class level declaration. Interesting... Good that we go with the local 8-byte approach, it improves the readability also. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19632#discussion_r1640166504