]> source.dussan.org Git - aspectj.git/commitdiff
309336: faster isAssignableFrom
authoraclement <aclement>
Fri, 16 Apr 2010 21:15:36 +0000 (21:15 +0000)
committeraclement <aclement>
Fri, 16 Apr 2010 21:15:36 +0000 (21:15 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java

index b876ad297e864bad4372485cce9da04987aac5b0..3d75c0bc378d5ece582e30f53cc881396e0b9ea9 100644 (file)
@@ -418,27 +418,22 @@ public class ReferenceType extends ResolvedType {
                        return true;
                }
 
-               if (this.getSignature().equals(ResolvedType.OBJECT.getSignature())) {
+               if (this.getSignature().equals("Ljava/lang/Object;")) {
                        return true;
                }
 
-               boolean thisRaw = this.isRawType();
-               boolean thisGeneric = this.isGenericType();
-
-               if ((thisRaw || thisGeneric) && other.isParameterizedType()) {
-                       if (isAssignableFrom(other.getRawType())) {
-                               return true;
-                       }
+               if (!isTypeVariableReference() && other.getSignature().equals("Ljava/lang/Object;")) {
+                       return false;
                }
-               if (thisRaw && other.isGenericType()) {
-                       if (isAssignableFrom(other.getRawType())) {
-                               return true;
-                       }
+
+               boolean thisRaw = this.isRawType();
+               if (thisRaw && other.isParameterizedOrGenericType()) {
+                       return isAssignableFrom(other.getRawType());
                }
-               if (thisGeneric && other.isRawType()) {
-                       if (isAssignableFrom(other.getGenericType())) {
-                               return true;
-                       }
+
+               boolean thisGeneric = this.isGenericType();
+               if (thisGeneric && other.isParameterizedOrRawType()) {
+                       return isAssignableFrom(other.getGenericType());
                }
 
                if (this.isParameterizedType()) {
@@ -527,19 +522,8 @@ public class ReferenceType extends ResolvedType {
                        }
                }
 
-               if (isTypeVariableReference() && !other.isTypeVariableReference()) { // eg
-                       // .
-                       // this
-                       // =
-                       // T
-                       // other
-                       // =
-                       // Ljava
-                       // /
-                       // lang
-                       // /
-                       // Object
-                       // ;
+               // eg this=T other=Ljava/lang/Object;
+               if (isTypeVariableReference() && !other.isTypeVariableReference()) {
                        TypeVariable aVar = ((TypeVariableReference) this).getTypeVariable();
                        return aVar.resolve(world).canBeBoundTo(other);
                }
@@ -564,13 +548,25 @@ public class ReferenceType extends ResolvedType {
 
                ResolvedType[] interfaces = other.getDeclaredInterfaces();
                for (ResolvedType intface : interfaces) {
-                       if (this.isAssignableFrom(intface, allowMissing)) {
+                       boolean b;
+                       if (thisRaw && intface.isParameterizedOrGenericType()) {
+                               b = this.isAssignableFrom(intface.getRawType(), allowMissing);
+                       } else {
+                               b = this.isAssignableFrom(intface, allowMissing);
+                       }
+                       if (b) {
                                return true;
                        }
                }
                ResolvedType superclass = other.getSuperclass();
                if (superclass != null) {
-                       if (this.isAssignableFrom(superclass, allowMissing)) {
+                       boolean b;
+                       if (thisRaw && superclass.isParameterizedOrGenericType()) {
+                               b = this.isAssignableFrom(superclass.getRawType(), allowMissing);
+                       } else {
+                               b = this.isAssignableFrom(superclass, allowMissing);
+                       }
+                       if (b) {
                                return true;
                        }
                }
index 42e57ef24b2bb2a6e6098858f7bb78344269a988..8436c228ecd0d7a0dc84f9a5a055fc9035761040 100644 (file)
@@ -177,6 +177,10 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
                return typeKind == TypeKind.GENERIC || typeKind == TypeKind.PARAMETERIZED;
        }
 
+       public boolean isParameterizedOrRawType() {
+               return typeKind == TypeKind.PARAMETERIZED || typeKind == TypeKind.RAW;
+       }
+
        public boolean isTypeVariableReference() {
                return typeKind == TypeKind.TYPE_VARIABLE;
        }