Added hack with null-check for escaping extra boxing for non-nullable keys in HashMap (#4174)

This commit is contained in:
LepilkinaElena
2020-05-15 17:45:33 +03:00
committed by GitHub
parent 6d5edf01bf
commit c485511f1b
@@ -190,7 +190,8 @@ actual class HashMap<K, V> private constructor(
return newValuesArray
}
private fun hash(key: K) = (key.hashCode() * MAGIC) ushr hashShift
// Null-check for escaping extra boxing for non-nullable keys.
private fun hash(key: K) = if (key == null) 0 else (key.hashCode() * MAGIC) ushr hashShift
private fun compact() {
var i = 0