]> source.dussan.org Git - aspectj.git/commitdiff
minor optimizations
authoraclement <aclement>
Sat, 7 Nov 2009 01:03:51 +0000 (01:03 +0000)
committeraclement <aclement>
Sat, 7 Nov 2009 01:03:51 +0000 (01:03 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignatureIterator.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildTypePattern.java

index fbade12120f2af6cc7cb5d0a1a4d408351d51ad4..1597989eda27d344c8412314a901418a9953e67b 100644 (file)
@@ -109,7 +109,8 @@ public class JoinPointSignatureIterator implements Iterator<JoinPointSignature>
                        return;
                }
 
-               firstDefiningMember = signaturesOfMember.resolve(world);
+               firstDefiningMember = (signaturesOfMember instanceof ResolvedMember ? 
+                   (ResolvedMember) signaturesOfMember: signaturesOfMember.resolve(world));
 
                if (firstDefiningMember == null) {
                        couldBeFurtherAsYetUndiscoveredSignatures = false;
index 94c55c25115718b2433f1505828c1a47a46851ae..3f8a01e6957cfb97ef7470e27cbe7f1c77810ec2 100644 (file)
@@ -326,8 +326,8 @@ public class DeclareAnnotation extends Declare {
                if (annotation != null) {
                        return;
                }
-               for (Iterator<ResolvedMember> iter = containingAspect.getMethods(false); iter.hasNext();) {
-                       ResolvedMember member = iter.next();
+               for (Iterator iter = containingAspect.getMethods(); iter.hasNext();) {
+                       ResolvedMember member = (ResolvedMember) iter.next();
                        if (member.getName().equals(annotationMethod)) {
                                AnnotationAJ[] annos = member.getAnnotations();
                                if (annos == null) {
@@ -388,8 +388,8 @@ public class DeclareAnnotation extends Declare {
         */
        public ResolvedType getAnnotationType() {
                if (annotationType == null) {
-                       for (Iterator<ResolvedMember> iter = containingAspect.getMethods(false); iter.hasNext();) {
-                               ResolvedMember member = iter.next();
+                       for (Iterator iter = containingAspect.getMethods(); iter.hasNext();) {
+                               ResolvedMember member = (ResolvedMember) iter.next();
                                if (member.getName().equals(annotationMethod)) {
                                        ResolvedType[] annoTypes = member.getAnnotationTypes();
                                        if (annoTypes == null) {
index 6dac7fff97bc29ee7b2aebff987154278b17baba..3ace8ac1e8b309cfdd03e0e23328ac3b3e78323d 100644 (file)
@@ -347,9 +347,12 @@ public class WildTypePattern extends TypePattern {
                        }
                } else {
                        for (int i = 0, len = knownMatches.length; i < len; i++) {
-                               String knownPrefix = knownMatches[i] + "$";
-                               if (targetTypeName.startsWith(knownPrefix)) {
-                                       int pos = lastIndexOfDotOrDollar(knownMatches[i]);
+                               String knownMatch = knownMatches[i];
+                               // String knownPrefix = knownMatches[i] + "$";
+                               // if (targetTypeName.startsWith(knownPrefix)) {
+                               if (targetTypeName.startsWith(knownMatch) && targetTypeName.length() > knownMatch.length()
+                                               && targetTypeName.charAt(knownMatch.length()) == '$') {
+                                       int pos = lastIndexOfDotOrDollar(knownMatch);
                                        if (innerMatchesExactly(targetTypeName.substring(pos + 1), isAnonymous, isNested)) {
                                                return true;
                                        }
@@ -374,14 +377,18 @@ public class WildTypePattern extends TypePattern {
        }
 
        private int lastIndexOfDotOrDollar(String string) {
-               int dot = string.lastIndexOf('.');
-               int dollar = string.lastIndexOf('$');
-               return Math.max(dot, dollar);
+               for (int pos = string.length() - 1; pos > -1; pos--) {
+                       char ch = string.charAt(pos);
+                       if (ch == '.' || ch == '$') {
+                               return pos;
+                       }
+               }
+               return -1;
        }
 
        private boolean innerMatchesExactly(String s, boolean isAnonymous, boolean convertDollar /* isNested */) {
 
-               List ret = new ArrayList();
+               List<char[]> ret = new ArrayList<char[]>();
                int startIndex = 0;
                while (true) {
                        int breakIndex = s.indexOf('.', startIndex); // what about /
@@ -412,7 +419,7 @@ public class WildTypePattern extends TypePattern {
                                return false;
                        }
                        while (patternsIndex < patternsLength) {
-                               if (!namePatterns[patternsIndex++].matches((char[]) ret.get(namesIndex++))) {
+                               if (!namePatterns[patternsIndex++].matches(ret.get(namesIndex++))) {
                                        return false;
                                }
                        }
@@ -426,7 +433,7 @@ public class WildTypePattern extends TypePattern {
                                if (p == NamePattern.ELLIPSIS) {
                                        namesIndex = namesLength - (patternsLength - patternsIndex);
                                } else {
-                                       if (!p.matches((char[]) ret.get(namesIndex++))) {
+                                       if (!p.matches(ret.get(namesIndex++))) {
                                                return false;
                                        }
                                }
@@ -434,8 +441,8 @@ public class WildTypePattern extends TypePattern {
                        return true;
                } else {
                        // System.err.print("match(\"" + Arrays.asList(namePatterns) + "\", \"" + Arrays.asList(names) + "\") -> ");
-                       boolean b = outOfStar(namePatterns, (char[][]) ret.toArray(new char[ret.size()][]), 0, 0, patternsLength
-                                       - ellipsisCount, namesLength, ellipsisCount);
+                       boolean b = outOfStar(namePatterns, ret.toArray(new char[ret.size()][]), 0, 0, patternsLength - ellipsisCount,
+                                       namesLength, ellipsisCount);
                        // System.err.println(b);
                        return b;
                }