On Sun, 3 Jul 2022 20:42:53 GMT, liach <d...@openjdk.org> wrote: >> Andrey Turbanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8288723: Avoid redundant ConcurrentHashMap.get call in java.time >> use computeIfAbsent where lambda could be short and static > > src/java.base/share/classes/java/time/format/DateTimeTextProvider.java line > 312: > >> 310: private Object findStore(TemporalField field, Locale locale) { >> 311: Entry<TemporalField, Locale> key = createEntry(field, locale); >> 312: return CACHE.computeIfAbsent(key, e -> createStore(e.getKey(), >> e.getValue())); > > If `createStore` can be static, the call site will only have to construct a > constant lambda than having to pass `this` to construct a new instance on > every call
Well, if you _really_ want to noodle this for performance, you can also store a `this`-bound lambda in a `private final` instance field, so then it's only created once too. I wouldn't put it past `javac` to do this, but I'd have to disassemble the bytecode of a little test program to see whether it's the case. ------------- PR: https://git.openjdk.org/jdk/pull/9208