groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring: remove the duplicated code further
Date Tue, 06 Feb 2018 08:37:25 GMT
Repository: groovy
Updated Branches:
  refs/heads/master e0c3cdf2f -> 6b208c17f


Minor refactoring: remove the duplicated code further


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

Branch: refs/heads/master
Commit: 6b208c17f004036f9f0c694acf644d5fd114d0ad
Parents: e0c3cdf
Author: sunlan <sunlan@apache.org>
Authored: Tue Feb 6 16:37:16 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Feb 6 16:37:16 2018 +0800

----------------------------------------------------------------------
 .../groovy/classgen/asm/BytecodeHelper.java     | 29 ++++++--------------
 1 file changed, 9 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6b208c17/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 a983af4..25fa258 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/BytecodeHelper.java
@@ -124,24 +124,15 @@ public class BytecodeHelper implements Opcodes {
      * @return the ASM type description for class loading
      */
     public static String getClassLoadingTypeDescription(ClassNode c) {
-        StringBuilder buf = new StringBuilder();
-        boolean array = false;
-        while (true) {
-            if (c.isArray()) {
-                buf.append('[');
-                c = c.getComponentType();
-                array = true;
-            } else {
-                if (ClassHelper.isPrimitiveType(c)) {
-                    buf.append(getTypeDescription(c));
-                } else {
-                    if (array) buf.append('L');
-                    buf.append(c.getName());
-                    if (array) buf.append(';');
-                }
-                return buf.toString();
+        String desc = TypeDescriptionUtil.getDescriptionByType(c);
+
+        if (!c.isArray()) {
+            if (desc.startsWith("L") && desc.endsWith(";")) {
+                desc = desc.substring(1, desc.length() - 1); // remove "L" and ";"
             }
         }
+
+        return desc.replace('/', '.');
     }
 
     /**
@@ -170,10 +161,8 @@ public class BytecodeHelper implements Opcodes {
 
         String desc = TypeDescriptionUtil.getDescriptionByType(d);
 
-        if (!end) {
-            if (desc.endsWith(";")) {
-                desc = desc.substring(0, desc.length() - 1);
-            }
+        if (!end && desc.endsWith(";")) {
+            desc = desc.substring(0, desc.length() - 1);
         }
 
         return desc;


Mime
View raw message