RFR: 8356126: Duplication handling and optimization of CaptureCallState [v5]
Jorn Vernee
jvernee at openjdk.org
Tue May 6 17:22:17 UTC 2025
On Tue, 6 May 2025 15:47:36 GMT, Chen Liang <liach at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/abi/CapturableState.java line 81:
>>
>>> 79:
>>> 80: public static CapturableState forName(String name) {
>>> 81: var ret = LOOKUP.get(name);
>>
>> As we usually have just one element (and for Windows three elements) it might be both less memory consuming and faster to just search a `@Stable` array linearly rather than having a Map.
>
> `Map.get` still has cleaner code than an array iteration, and there is already a Map1 optimized implementation. I think map is more friendly in the long run.
Alternatively, you could hard code the names in a `switch` here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25025#discussion_r2075939248
More information about the core-libs-dev
mailing list