diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java index f70c831b2be..ceedab43fc9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java @@ -44,17 +44,21 @@ public abstract class AbstractClassTypeConstructor implements TypeConstructor { public static boolean equals(@NotNull TypeConstructor me, Object other) { if (!(other instanceof TypeConstructor)) return false; + // performance optimization: getFqName is slow method + if (other.hashCode() != me.hashCode()) return false; + ClassifierDescriptor myDescriptor = me.getDeclarationDescriptor(); ClassifierDescriptor otherDescriptor = ((TypeConstructor) other).getDeclarationDescriptor(); + // descriptor for type is created once per module + if (myDescriptor == otherDescriptor) return true; + // All error types have the same descriptor if (myDescriptor != null && !hasMeaningfulFqName(myDescriptor) || otherDescriptor != null && !hasMeaningfulFqName(otherDescriptor)) { return me == other; } - if (myDescriptor == otherDescriptor) return true; - if (myDescriptor instanceof ClassDescriptor && otherDescriptor instanceof ClassDescriptor) { FqNameUnsafe otherFqName = DescriptorUtils.getFqName(otherDescriptor); FqNameUnsafe myFqName = DescriptorUtils.getFqName(myDescriptor);