Re: Useless null check in HashMap.merge()

2018-07-05 Thread Martin Buchholz
The null check will be removed as part of the next jsr166 integration. http://cr.openjdk.java.net/~martin/webrevs/jdk/jsr166-integration/miscellaneous/index.html On Wed, Jul 4, 2018 at 2:42 AM, Zheka Kozlov wrote: > I noticed dead code in java.util.HashMap.merge(): > > public V merge(K key, V va

Re: Useless null check in HashMap.merge()

2018-07-04 Thread Doug Lea
On 07/04/2018 09:22 AM, Zheka Kozlov wrote: > Oh yes, you are right. Then this is not dead code, just a useless null > check. My vague recollection is that the check was there to ensure that the block was identical to those in the other methods when considering ways to factor it out (none of which

Re: Useless null check in HashMap.merge()

2018-07-04 Thread Jim Laskey
Just as a note, it is reasonable to make value “final” so that value can not be nulled out between the test and its use. Cheers, — Jim > On Jul 4, 2018, at 10:22 AM, Zheka Kozlov wrote: > > Oh yes, you are right. Then this is not dead code, just a useless null > check. > > 2018-07-04 19:55

Re: Useless null check in HashMap.merge()

2018-07-04 Thread Zheka Kozlov
Oh yes, you are right. Then this is not dead code, just a useless null check. 2018-07-04 19:55 GMT+07:00 Scott Palmer : > On Jul 4, 2018, at 5:42 AM, Zheka Kozlov wrote: > > > > I noticed dead code in java.util.HashMap.merge(): > > > > public V merge(K key, V value, > > BiFunct

Re: Useless null check in HashMap.merge()

2018-07-04 Thread Scott Palmer
On Jul 4, 2018, at 5:42 AM, Zheka Kozlov wrote: > > I noticed dead code in java.util.HashMap.merge(): > > public V merge(K key, V value, > BiFunction > remappingFunction) { >if (value == null) >throw new NullPointerException(); > >... > >if (value != null)

Useless null check in HashMap.merge()

2018-07-04 Thread Zheka Kozlov
I noticed dead code in java.util.HashMap.merge(): public V merge(K key, V value, BiFunction remappingFunction) { if (value == null) throw new NullPointerException(); ... if (value != null) { *// Condition ' value != null' is always true* if (t != nu