groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [1/4] groovy git commit: Minor refactoring: remove duplicated code
Date Wed, 07 Feb 2018 14:59:01 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X b1cc4fcc7 -> e89f8a01d


Minor refactoring: remove duplicated code

(cherry picked from commit 08d1082)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 7442aa376233a8282f04b6a14ba06530014e00cf
Parents: b1cc4fc
Author: Daniel Sun <realbluesun@hotmail.com>
Authored: Wed Feb 7 21:50:27 2018 +0800
Committer: Daniel Sun <realbluesun@hotmail.com>
Committed: Wed Feb 7 22:58:37 2018 +0800

----------------------------------------------------------------------
 .../groovy/classgen/asm/BytecodeHelper.java     |  2 +-
 .../groovy/classgen/asm/OperandStack.java       | 34 +-------------------
 2 files changed, 2 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7442aa37/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
index 25fa258..af464f4 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
@@ -207,7 +207,7 @@ public class BytecodeHelper implements Opcodes {
                 } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE)
{
                     mv.visitIntInsn(SIPUSH, value);
                 } else {
-                    mv.visitLdcInsn(Integer.valueOf(value));
+                    mv.visitLdcInsn(value);
                 }
         }
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/7442aa37/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 9ba551e..f8a494c 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
@@ -66,10 +66,6 @@ import static org.objectweb.asm.Opcodes.I2L;
 import static org.objectweb.asm.Opcodes.I2S;
 import static org.objectweb.asm.Opcodes.ICONST_0;
 import static org.objectweb.asm.Opcodes.ICONST_1;
-import static org.objectweb.asm.Opcodes.ICONST_2;
-import static org.objectweb.asm.Opcodes.ICONST_3;
-import static org.objectweb.asm.Opcodes.ICONST_4;
-import static org.objectweb.asm.Opcodes.ICONST_5;
 import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
 import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
 import static org.objectweb.asm.Opcodes.L2D;
@@ -80,7 +76,6 @@ import static org.objectweb.asm.Opcodes.LCONST_1;
 import static org.objectweb.asm.Opcodes.NEW;
 import static org.objectweb.asm.Opcodes.POP;
 import static org.objectweb.asm.Opcodes.POP2;
-import static org.objectweb.asm.Opcodes.SIPUSH;
 import static org.objectweb.asm.Opcodes.SWAP;
 
 public class OperandStack {
@@ -535,34 +530,7 @@ public class OperandStack {
         boolean isChar = ClassHelper.char_TYPE.equals(type);
         if (isInt || isShort || isByte || isChar) {
             int val = isInt?(Integer)value:isShort?(Short)value:isChar?(Character)value:(Byte)value;
-            switch (val) {
-                case 0:
-                    mv.visitInsn(ICONST_0);
-                    break;
-                case 1:
-                    mv.visitInsn(ICONST_1);
-                    break;
-                case 2:
-                    mv.visitInsn(ICONST_2);
-                    break;
-                case 3:
-                    mv.visitInsn(ICONST_3);
-                    break;
-                case 4:
-                    mv.visitInsn(ICONST_4);
-                    break;
-                case 5:
-                    mv.visitInsn(ICONST_5);
-                    break;
-                default:
-                    if (val>=Byte.MIN_VALUE && val<=Byte.MAX_VALUE) {
-                        mv.visitIntInsn(BIPUSH, val);
-                    } else if (val>=Short.MIN_VALUE && val<=Short.MAX_VALUE)
{
-                        mv.visitIntInsn(SIPUSH, val);
-                    } else {
-                        mv.visitLdcInsn(value);
-                    }
-            }
+            BytecodeHelper.pushConstant(mv, val);
         } else if (ClassHelper.long_TYPE.equals(type)) {
             if ((Long)value==0L) {
                 mv.visitInsn(LCONST_0);


Mime
View raw message