]> source.dussan.org Git - aspectj.git/commitdiff
intelligent use of match info determined earlier
authoraclement <aclement>
Fri, 13 Nov 2009 18:25:56 +0000 (18:25 +0000)
committeraclement <aclement>
Fri, 13 Nov 2009 18:25:56 +0000 (18:25 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 0e04fe37b6308c6183b4ece385c921b5235e7b57..0abbc9911d9bd8be2275e4fa46c4f0ac8fd0dcaf 100644 (file)
@@ -3072,39 +3072,52 @@ class BcelClassWeaver implements IClassWeaver {
                        ContextToken shadowMatchToken = CompilationAndWeavingContext.enteringPhase(
                                        CompilationAndWeavingContext.MATCHING_SHADOW, shadow);
                        boolean isMatched = false;
-                       for (ShadowMunger munger : shadowMungers) {
-                               ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(
-                                               CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
-                               if (munger.match(shadow, world)) {
-                                       shadow.addMunger(munger);
-                                       isMatched = true;
-                                       if (shadow.getKind() == Shadow.StaticInitialization) {
-                                               clazz.warnOnAddedStaticInitializer(shadow, munger.getSourceLocation());
+
+                       Shadow.Kind shadowKind = shadow.getKind();
+                       List<ShadowMunger> candidateMungers = perKindShadowMungers[shadowKind.getKey()];
+
+                       // System.out.println("Candidates " + candidateMungers);
+                       if (candidateMungers != null) {
+                               for (ShadowMunger munger : candidateMungers) {
+
+                                       ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(
+                                                       CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
+                                       if (munger.match(shadow, world)) {
+                                               shadow.addMunger(munger);
+                                               isMatched = true;
+                                               if (shadow.getKind() == Shadow.StaticInitialization) {
+                                                       clazz.warnOnAddedStaticInitializer(shadow, munger.getSourceLocation());
+                                               }
                                        }
+                                       CompilationAndWeavingContext.leavingPhase(mungerMatchToken);
                                }
-                               CompilationAndWeavingContext.leavingPhase(mungerMatchToken);
-                       }
 
-                       if (isMatched) {
-                               shadowAccumulator.add(shadow);
+                               if (isMatched) {
+                                       shadowAccumulator.add(shadow);
+                               }
                        }
                        CompilationAndWeavingContext.leavingPhase(shadowMatchToken);
                        return isMatched;
                } else {
                        boolean isMatched = false;
-                       int max = shadowMungers.size();
-                       for (int i = 0; i < max; i++) {
-                               ShadowMunger munger = shadowMungers.get(i);
-                               if (munger.match(shadow, world)) {
-                                       shadow.addMunger(munger);
-                                       isMatched = true;
-                                       if (shadow.getKind() == Shadow.StaticInitialization) {
-                                               clazz.warnOnAddedStaticInitializer(shadow, munger.getSourceLocation());
+
+                       Shadow.Kind shadowKind = shadow.getKind();
+                       List<ShadowMunger> candidateMungers = perKindShadowMungers[shadowKind.getKey()];
+
+                       // System.out.println("Candidates at " + shadowKind + " are " + candidateMungers);
+                       if (candidateMungers != null) {
+                               for (ShadowMunger munger : candidateMungers) {
+                                       if (munger.match(shadow, world)) {
+                                               shadow.addMunger(munger);
+                                               isMatched = true;
+                                               if (shadow.getKind() == Shadow.StaticInitialization) {
+                                                       clazz.warnOnAddedStaticInitializer(shadow, munger.getSourceLocation());
+                                               }
                                        }
                                }
-                       }
-                       if (isMatched) {
-                               shadowAccumulator.add(shadow);
+                               if (isMatched) {
+                                       shadowAccumulator.add(shadow);
+                               }
                        }
                        return isMatched;
                }