On Sun, 3 Jul 2022 22:06:58 GMT, Attila Szegedi <[email protected]> wrote:
>> 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.
Can there be some JMH tests to confirm the performance?
The value domain of the keys is pretty limited (7 * 7) max; and I'm not sure
that the combination of creating a new record and the hashcode and equals
methods would be faster than string concat of a constant and a single digit
integer.
-------------
PR: https://git.openjdk.org/jdk/pull/9208