RFR: 8339196: Optimize BufWriterImpl#writeU1/U2/Int/Long

Shaojin Wen swen at openjdk.org
Thu Aug 29 12:23:22 UTC 2024


On Wed, 28 Aug 2024 13:16:03 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> A small optimization makes BufWriterImpl's writeU1/U2/Int/Long methods more C2-friendly and improves performance.

The general way of writing should be like this:

elems[offset++] = (byte) (intValue >>> 8 * (intSize - i - 1));
``` 


* now

(byte) ((x >> 8) & 0xFF)


Is the & 0xFF here redundant? I am confused

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

PR Comment: https://git.openjdk.org/jdk/pull/20748#issuecomment-2317491283


More information about the core-libs-dev mailing list