RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v2]
ExE Boss
duke at openjdk.org
Fri Oct 14 12:11:06 UTC 2022
On Fri, 14 Oct 2022 08:53:24 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:
>
> Update src/java.base/share/classes/java/util/TreeMap.java
>
> Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
src/java.base/share/classes/java/util/TreeMap.java line 3320:
> 3318: @SuppressWarnings("unchecked")
> 3319: Comparator<Map.Entry<K, V>> entryComparator = treeComparator == null ?
> 3320: (Comparator) Map.Entry.comparingByKey()
Missed a colon:
Suggestion:
(Comparator) Map.Entry.comparingByKey() :
-------------
PR: https://git.openjdk.org/jdk/pull/9901
More information about the core-libs-dev
mailing list