Looking java's hashmap implementation, not able to understand the reason behind some lines. In below code copied from here, in line 365-367, I am not able to understand why have they done the assignment of e.key to k first and then compared == with key [ (k = e.key) == key ]. Why not directly do (e.key == key) . This pattern appears several times in code.
359
360 final Entry<K,V> getEntry(Object key) {
361 int hash = (key == null) ? 0 : hash(key.hashCode());
362 for (Entry<K,V> e = table[indexFor(hash, table.length)];
363 e != null;
364 e = e.next) {
365 Object k;
366 if (e.hash == hash &&
367 ((k = e.key) == key || (key != null && key.equals(k))))
368 return e;
369 }
370 return null;
371 }