Re: RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v2]

2022-10-14 Thread ExE Boss
On Fri, 14 Oct 2022 08:53:24 GMT, Сергей Цыпанов 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.getEntryUsin

Re: RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v2]

2022-10-14 Thread Сергей Цыпанов
On Thu, 13 Oct 2022 21:46:15 GMT, ExE Boss wrote: >> Nope, there'd be a compilation error > > It'll work fine if an unchecked cast is used: > Suggestion: > > @SuppressWarnings("unchecked") > Comparator> entryComparator = treeComparator == > null ? > (

Re: RFR: 8293630: Simplify TreeMap.get() with Comparator.naturalOrder() [v2]

2022-10-14 Thread Сергей Цыпанов
> 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? Серге