On Fri, 27 Sep 2024 17:05:25 GMT, Shaojin Wen <[email protected]> wrote:
> A small optimization to reduce the write operations of trimAndCompress
We can improve performance by avoiding repeated array access in the loop.
Instead of accessing types[i] multiple times, we cache it in a local variable.
Here's the optimized version
`for (int i = 0; i < count; i++) {
Type current = types[i];
if (!current.isCategory2_2nd()) {
if (compressed != i) {
types[compressed] = current;
}
compressed++;
}
}
` This reduces overhead from multiple array lookups.
-------------
Changes requested by [email protected] (no known OpenJDK username).
PR Review: https://git.openjdk.org/jdk/pull/21227#pullrequestreview-2335379912