Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X a8d5e864e -> 05b366d5f


Trivial refactoring: extract variable


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/05b366d5
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/05b366d5
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/05b366d5

Branch: refs/heads/GROOVY_2_4_X
Commit: 05b366d5f58e17db377083613510cc2c32eed982
Parents: a8d5e86
Author: sunlan <[email protected]>
Authored: Thu Jan 11 15:28:20 2018 +0800
Committer: sunlan <[email protected]>
Committed: Thu Jan 11 15:28:20 2018 +0800

----------------------------------------------------------------------
 .../classgen/asm/sc/StaticInvocationWriter.java | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/05b366d5/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
----------------------------------------------------------------------
diff --git 
a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java 
b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 92596dd..234cf2f 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -353,16 +353,17 @@ public class StaticInvocationWriter extends 
InvocationWriter {
         AsmClassGenerator acg = controller.getAcg();
         TypeChooser typeChooser = controller.getTypeChooser();
         OperandStack operandStack = controller.getOperandStack();
-        ClassNode lastArgType = !argumentList.isEmpty() ?
-                
typeChooser.resolveType(argumentList.get(argumentList.size()-1), 
controller.getClassNode()):null;
+        int argumentListSize = argumentList.size();
+        ClassNode lastArgType = argumentListSize > 0 ?
+                typeChooser.resolveType(argumentList.get(argumentListSize -1), 
controller.getClassNode()):null;
         if (lastParaType.isArray()
-                && ((argumentList.size() > para.length)
-                || ((argumentList.size() == (para.length - 1)) && 
!lastParaType.equals(lastArgType))
-                || ((argumentList.size() == para.length && lastArgType!=null 
&& !lastArgType.isArray())
+                && ((argumentListSize > para.length)
+                || ((argumentListSize == (para.length - 1)) && 
!lastParaType.equals(lastArgType))
+                || ((argumentListSize == para.length && lastArgType!=null && 
!lastArgType.isArray())
                     && 
(StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(lastArgType,lastParaType.getComponentType())))
                         || ClassHelper.GSTRING_TYPE.equals(lastArgType) && 
ClassHelper.STRING_TYPE.equals(lastParaType.getComponentType()))
                 ) {
-            int stackLen = operandStack.getStackLength() + argumentList.size();
+            int stackLen = operandStack.getStackLength() + argumentListSize;
             MethodVisitor mv = controller.getMethodVisitor();
             //mv = new org.objectweb.asm.util.TraceMethodVisitor(mv);
             controller.setMethodVisitor(mv);
@@ -377,7 +378,7 @@ public class StaticInvocationWriter extends 
InvocationWriter {
             }
             // last parameters wrapped in an array
             List<Expression> lastParams = new LinkedList<Expression>();
-            for (int i = para.length - 1; i < argumentList.size(); i++) {
+            for (int i = para.length - 1; i < argumentListSize; i++) {
                 lastParams.add(argumentList.get(i));
             }
             ArrayExpression array = new ArrayExpression(
@@ -389,11 +390,11 @@ public class StaticInvocationWriter extends 
InvocationWriter {
             while (operandStack.getStackLength() < stackLen) {
                 operandStack.push(ClassHelper.OBJECT_TYPE);
             }
-            if (argumentList.size() == para.length - 1) {
+            if (argumentListSize == para.length - 1) {
                 operandStack.remove(1);
             }
-        } else if (argumentList.size() == para.length) {
-            for (int i = 0; i < argumentList.size(); i++) {
+        } else if (argumentListSize == para.length) {
+            for (int i = 0; i < argumentListSize; i++) {
                 Expression expression = argumentList.get(i);
                 expression.visit(acg);
                 if (!isNullConstant(expression)) {
@@ -407,7 +408,7 @@ public class StaticInvocationWriter extends 
InvocationWriter {
             for (int i = 0, j = 0; i < para.length; i++) {
                 Parameter curParam = para[i];
                 ClassNode curParamType = curParam.getType();
-                Expression curArg = j < argumentList.size() ? 
argumentList.get(j) : null;
+                Expression curArg = j < argumentListSize ? argumentList.get(j) 
: null;
                 Expression initialExpression = 
curParam.getNodeMetaData(StaticTypesMarker.INITIAL_EXPRESSION);
                 if (initialExpression == null && 
curParam.hasInitialExpression())
                     initialExpression = curParam.getInitialExpression();

Reply via email to