You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/02/07 23:59:36 UTC

[2/2] groovy git commit: Trivial refactoring: reuse `size` variable of `castToBool`

Trivial refactoring: reuse `size` variable of `castToBool`


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

Branch: refs/heads/master
Commit: c376685de0b93bdcea049369bbcb1fb06a2e0bf8
Parents: 95c2cf7
Author: sunlan <su...@apache.org>
Authored: Thu Feb 8 07:56:56 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Thu Feb 8 07:56:56 2018 +0800

----------------------------------------------------------------------
 .../groovy/classgen/asm/OperandStack.java         | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c376685d/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java b/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
index 105a8b4..5dc3743 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
@@ -135,7 +135,7 @@ public class OperandStack {
     public void castToBool(int mark, boolean emptyDefault) {
         int size = stack.size();
         MethodVisitor mv = controller.getMethodVisitor();
-        if (mark==size) {
+        if (mark == size) {
             // no element, so use emptyDefault
             if (emptyDefault) {
                 mv.visitIntInsn(BIPUSH, 1);
@@ -143,8 +143,8 @@ public class OperandStack {
                 mv.visitIntInsn(BIPUSH, 0);
             }
             stack.add(null);
-        } else if (mark==stack.size()-1) {
-            ClassNode last =  stack.get(size-1);
+        } else if (mark == size - 1) {
+            ClassNode last = stack.get(size - 1);
             // nothing to do in that case
             if (last == ClassHelper.boolean_TYPE) return;
             // not a primitive type, so call booleanUnbox
@@ -152,14 +152,14 @@ public class OperandStack {
                 controller.getInvocationWriter().castNonPrimitiveToBool(last);
             } else {
                 BytecodeHelper.convertPrimitiveToBoolean(mv, last);
-            }            
-        } else { 
+            }
+        } else {
             throw new GroovyBugError(
-                    "operand stack contains "+stack.size()+
-                    " elements, but we expected only "+mark
-                );
+                    "operand stack contains " + size +
+                            " elements, but we expected only " + mark
+            );
         }
-        stack.set(mark,ClassHelper.boolean_TYPE);
+        stack.set(mark, ClassHelper.boolean_TYPE);
     }
 
     /**