I am new to generics and I am not sure if the answer to my question is opinion based
or has a genuine reason. In the following code what was need to case a key of an entry to an object ?
Object k;
if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k))))
It appears to be easily replaced by
if (e.hash == hash && (e.key == key || (key != null && key.equals(e.key))))
More reference:
final Entry<K,V> getEntry(Object key) {
int hash = (key == null) ? 0 : hash(key);
for (Entry<K,V> e = table[indexFor(hash, table.length)];
e != null;
e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k))))
return e;
}
return null;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…