RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v4]
liach
duke at openjdk.org
Mon Oct 17 19:46:04 UTC 2022
On Mon, 17 Oct 2022 10:19:26 GMT, Сергей Цыпанов <duke at openjdk.org> wrote:
>> We can use `Comparator.naturalOrder()` for cases when a `TreeMap` instance is constructed without comparator. This allows to squash two branches in `TreeMap.get()` into one.
>>
>> P.S. I think the comment of `TreeMap.getEntryUsingComparator()` is outdated. Should we also change it?
>
> Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision:
>
> 8293630: Inline natural()
src/java.base/share/classes/java/util/TreeMap.java line 3329:
> 3327: }
> 3328: else {
> 3329: return (Comparator<Map.Entry<K, V>> & Serializable) (e1, e2) -> {
I think this cast hints compiler to bootstrap lambda meta factory with extra Serializable marker interface. Meanwhile, Comparator.naturalOrder does not implement Serializable.
-------------
PR: https://git.openjdk.org/jdk/pull/9901
More information about the core-libs-dev
mailing list