From: aclement Date: Fri, 13 Nov 2009 18:25:56 +0000 (+0000) Subject: intelligent use of match info determined earlier X-Git-Tag: V1_6_7~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd52f6369ee15bb8ee410a3a3720b957cbfe22a3;p=aspectj.git intelligent use of match info determined earlier --- diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 0e04fe37b..0abbc9911 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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 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 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; }