Fix performance regression in NI by fixing totally incorrect hashCode

The actual problem was introduced in 4f1e85b468, note how `hashCode` is implemented:
```
var currentHashCode = cachedHashCode
if (currentHashCode == 0) return currentHashCode
...
```
It's a silly bug, there should be check `if (currentHashCode != 0) ...` because `0` is used a marker for "uncomputed value".

Now, in the commit 0219b86d06 I added map with `KotlinType` as a key and because of constant `hash` for `KotlinType`, we basically got `List` instead of `Map`, which caused this performance regression

 #KT-34063 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-09-30 02:04:39 +03:00
parent 957af741cd
commit 932d84d568
8 changed files with 212 additions and 7 deletions
@@ -0,0 +1,178 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
val prop = mapOf(
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b"),
to("a", "b")
)
fun <A, B> to(a: A, b: B): Pair<A, B> = TODO()
fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> = TODO()
class Pair<out A, out B>
@@ -0,0 +1,12 @@
package
public val prop: kotlin.collections.Map<kotlin.String, kotlin.String>
public fun </*0*/ K, /*1*/ V> mapOf(/*0*/ vararg pairs: Pair<K, V> /*kotlin.Array<out Pair<K, V>>*/): kotlin.collections.Map<K, V>
public fun </*0*/ A, /*1*/ B> to(/*0*/ a: A, /*1*/ b: B): Pair<A, B>
public final class Pair</*0*/ out A, /*1*/ out B> {
public constructor Pair</*0*/ out A, /*1*/ out B>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}