Checks reordered for better performance

This commit is contained in:
Andrey Breslav
2011-09-06 11:56:20 +04:00
parent 93a422ae0a
commit f5928be33e
2 changed files with 8 additions and 9 deletions
+4 -4
View File
@@ -81,20 +81,20 @@ public abstract class TypeInfo<T> implements JetObject {
}
public final boolean isInstance(Object obj) {
if (obj == null) return nullable;
if (obj instanceof JetObject) {
return ((JetObject) obj).getTypeInfo().isSubtypeOf(this);
}
if (obj == null)
return nullable;
return theClass.isAssignableFrom(obj.getClass()); // TODO
}
public final boolean isSubtypeOf(TypeInfo<?> superType) {
if (!superType.theClass.isAssignableFrom(theClass)) {
if (nullable && !superType.nullable) {
return false;
}
if (nullable && !superType.nullable) {
if (!superType.theClass.isAssignableFrom(theClass)) {
return false;
}
if (projections != null) {