On Thu, 14 Nov 2024 20:49:55 GMT, Anthony Scarpino <ascarp...@openjdk.org> wrote:
>> src/java.base/share/classes/com/sun/crypto/provider/CipherBlockChaining.java >> line 222: >> >>> 220: processed += >>> 221: implDecrypt(cipher, cipherOffset, cipherLen, plain, >>> plainOffset); >>> 222: return processed; >> >> The `for` loop logic is the same for encrypt and decrypt operations, only >> different positioning of the arguments. How about creating a helper method >> `chunkOperation` that would take one additional encrypt/decrypt boolean >> argument based on which it would do either encrypt or decrypt operation. > > Given this is a performance change, I'm fine with leaving it as is. Jumping > to a helper method with an encrypt/decrypt conditional check for every crypto > op will costs performance. This is a case where more efficient code is more > verbose syntax. @ascarpino But a method call should be very cheap, we are adding a bunch of extra implEncrypt/implDecrypt calls here already. Besides, compiler/hotspot will optimize that call if needed. It will be just a method wrapping the `for` loop. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22086#discussion_r1842881324