Looking at HashMap.getNode(Object key)
method in OpenJDK we see a local variables tab
initialized by assigning the transient Node<K,V>[] table;
field to it:
final Node<K,V> getNode(Object key) {
Node<K,V>[] tab; Node<K,V> first, e; int n, hash; K k;
if ((tab = table) != null && (n = tab.length) > 0 &&
(first = tab[(n - 1) & (hash = hash(key))]) != null) {
...
What's the benefit of assigning table
field into tab
local variable?
Why later in the code it's first = tab[...]
instead of first = table[...]
?