From fd52f6369ee15bb8ee410a3a3720b957cbfe22a3 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 13 Nov 2009 18:25:56 +0000 Subject: [PATCH] intelligent use of match info determined earlier --- .../aspectj/weaver/bcel/BcelClassWeaver.java | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) 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; } -- 2.39.5