optimizations for instanceof List<*>

This commit is contained in:
Alex Tkachman
2011-12-14 12:44:07 +02:00
parent 91a7930555
commit 9aaf20bc95
3 changed files with 14 additions and 10 deletions
@@ -2475,9 +2475,13 @@ If finally block is present, its last expression is the value of try expression.
return hasTypeInfoForInstanceOf(type.getArguments().get(0).getType());
}
for(TypeParameterDescriptor proj : classDescriptor.getTypeConstructor().getParameters()) {
if(proj.isReified()) {
return true;
for (int i = 0; i < type.getArguments().size(); i++) {
TypeParameterDescriptor typeParameterDescriptor = classDescriptor.getTypeConstructor().getParameters().get(i);
if(typeParameterDescriptor.isReified()) {
TypeProjection typeProjection = type.getArguments().get(i);
if( !typeProjection.getType().equals(typeParameterDescriptor.getUpperBoundsAsType())) {
return true;
}
}
}
+2 -2
View File
@@ -30,7 +30,7 @@ class StandardFList<T> (override val head: T, override val tail: FList<T>) : FLi
fun <T> FList<T>.plus2(element: T): FList<T> =
when(this) {
is EmptyFList<T> => OneElementFList<T>(element)
is EmptyFList<*> => OneElementFList<T>(element)
else => StandardFList<T>(element, this)
}
@@ -67,4 +67,4 @@ fun main(args: Array<String>) {
System.out?.println(System.currentTimeMillis() - start2)
System.out?.println()
}
}
}
+5 -5
View File
@@ -376,7 +376,7 @@ public abstract class TypeInfo<T> implements JetObject {
return false;
}
if (superType.projections == null || superType.projections.length != projections.length) {
throw new IllegalArgumentException("inconsistent type infos for the same class");
throw new IllegalArgumentException("inconsistent type info for the same class");
}
for (int i = 0; i < projections.length; i++) {
// TODO handle variance here
@@ -451,18 +451,18 @@ public abstract class TypeInfo<T> implements JetObject {
if(klass == null)
return null;
lock.readLock().lock();
// lock.readLock().lock();
Signature sig = map.get(klass);
lock.readLock().unlock();
// lock.readLock().unlock();
if (sig == null) {
lock.writeLock().lock();
// lock.writeLock().lock();
sig = map.get(klass);
if (sig == null) {
sig = internalParse(klass);
}
lock.writeLock().unlock();
// lock.writeLock().unlock();
}
return sig;
}