From db70f92aa10ee2fbf15f5ec1e2ed3d68cc2b6baf Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 13 Nov 2009 18:24:12 +0000 Subject: [PATCH] faster parametercount checking --- .../weaver/patterns/SignaturePattern.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java index 00eea30e4..52115f7e4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -436,22 +436,25 @@ public class SignaturePattern extends PatternNode { // just give up early (for now) return false; } + int patternParameterCount = parameterTypes.size(); - int joinpointParameterCount = methodJoinpoint.getParameterTypes().length; - boolean isVarargs = methodJoinpoint.isVarargsMethod(); - // Quick rule: pattern specifies zero parameters, and joinpoint has parameters *OR* - if (patternParameterCount == 0 && joinpointParameterCount > 0) { // varargs may allow this - return true; - } + if (patternParameterCount == 0 || parameterTypes.ellipsisCount == 0) { + boolean equalCount = patternParameterCount == methodJoinpoint.getParameterTypes().length; - // Quick rule: pattern doesn't specify ellipsis and there are a different number of parameters on the - // method join point as compared with the pattern - if (parameterTypes.ellipsisCount == 0 && patternParameterCount != joinpointParameterCount) { - if (patternParameterCount > 0 && parameterTypes.get(patternParameterCount - 1).isVarArgs()) { - return false; + // Quick rule: pattern specifies zero parameters, and joinpoint has parameters *OR* + if (patternParameterCount == 0 && !equalCount) { + return true; + } + + // Quick rule: pattern doesn't specify ellipsis and there are a different number of parameters on the + // method join point as compared with the pattern + if (parameterTypes.ellipsisCount == 0 && !equalCount) { + if (patternParameterCount > 0 && parameterTypes.get(patternParameterCount - 1).isVarArgs()) { + return false; + } + return true; } - return true; } return false; -- 2.39.5