On Tue, 6 May 2025 15:47:36 GMT, Chen Liang <li...@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

Reply via email to