RFR: 8341136: Optimize StackMapGenerator::trimAndCompress
Abdelhak Zaaim
duke at openjdk.org
Sat Sep 28 17:18:34 UTC 2024
On Fri, 27 Sep 2024 17:05:25 GMT, Shaojin Wen <swen at openjdk.org> 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 abdelhak-zaaim at github.com (no known OpenJDK username).
PR Review: https://git.openjdk.org/jdk/pull/21227#pullrequestreview-2335379912
More information about the core-libs-dev
mailing list