avoid unnecessary and expensive creation of FqName instances
This commit is contained in:
@@ -827,7 +827,9 @@ public class KotlinBuiltIns {
|
|||||||
|
|
||||||
private static boolean isConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
|
private static boolean isConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
|
||||||
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
return descriptor != null && fqName.equals(getFqName(descriptor));
|
return descriptor != null &&
|
||||||
|
/* quick check to avoid creation of full FqName instance */ descriptor.getName().equals(fqName.shortName()) &&
|
||||||
|
fqName.equals(getFqName(descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isNotNullConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
|
private static boolean isNotNullConstructedFromGivenClass(@NotNull JetType type, @NotNull FqNameUnsafe fqName) {
|
||||||
|
|||||||
@@ -23,9 +23,16 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
|
|
||||||
public abstract class AbstractClassTypeConstructor implements TypeConstructor {
|
public abstract class AbstractClassTypeConstructor implements TypeConstructor {
|
||||||
|
private boolean hashCodeComputed;
|
||||||
|
private int hashCode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int hashCode() {
|
public final int hashCode() {
|
||||||
return hashCode(this);
|
if (!hashCodeComputed) {
|
||||||
|
hashCodeComputed = true;
|
||||||
|
hashCode = hashCode(this);
|
||||||
|
}
|
||||||
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user