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) {
|
||||
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) {
|
||||
|
||||
@@ -23,9 +23,16 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
|
||||
public abstract class AbstractClassTypeConstructor implements TypeConstructor {
|
||||
private boolean hashCodeComputed;
|
||||
private int hashCode;
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return hashCode(this);
|
||||
if (!hashCodeComputed) {
|
||||
hashCodeComputed = true;
|
||||
hashCode = hashCode(this);
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user