avoid unnecessary and expensive creation of FqName instances

This commit is contained in:
Dmitry Jemerov
2015-06-02 14:48:52 +02:00
parent d1df234cfe
commit 9672264442
2 changed files with 11 additions and 2 deletions
@@ -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