groovy git commit: Trivial refactoring: simplify testing array type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: Trivial refactoring: simplify testing array type

Daniel.Sun
Repository: groovy
Updated Branches:
  refs/heads/master 20b2f3cb5 -> a8b9be9e6


Trivial refactoring: simplify testing array type


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

Branch: refs/heads/master
Commit: a8b9be9e6c19c1a1193abdfeffaf1f113beb1270
Parents: 20b2f3c
Author: danielsun1106 <[hidden email]>
Authored: Sat Mar 10 02:09:25 2018 +0800
Committer: danielsun1106 <[hidden email]>
Committed: Sat Mar 10 02:09:25 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/asm/util/TypeUtil.java   | 10 +++++-----
 .../java/org/codehaus/groovy/reflection/ClassInfo.java    |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/a8b9be9e/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java b/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java
index 23fbebc..9b79858 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/util/TypeUtil.java
@@ -52,6 +52,11 @@ import static org.objectweb.asm.Opcodes.LRETURN;
  * @since 2.5.0
  */
 public abstract class TypeUtil {
+    public static Class autoboxType(Class type) {
+        final Class res = PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP.get(type);
+        return res == null ? type : res;
+    }
+
     public static int getLoadInsnByType(Type type) {
         Integer insn = PRIMITIVE_TYPE_TO_LOAD_INSN_MAP.get(type);
 
@@ -140,11 +145,6 @@ public abstract class TypeUtil {
         return new Tuple2<ClassNode, Integer>(type, dimension);
     }
 
-    public static Class autoboxType(Class type) {
-        final Class res = PRIMITIVE_TYPE_TO_WRAPPED_CLASS_MAP.get(type);
-        return res == null ? type : res;
-    }
-
     private static final String REF_DESCRIPTION = "L";
     private static final Map<ClassNode, String> PRIMITIVE_TYPE_TO_DESCRIPTION_MAP = Maps.of(
             int_TYPE, "I",

http://git-wip-us.apache.org/repos/asf/groovy/blob/a8b9be9e/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
index b4dc133..c7abeff 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
@@ -384,7 +384,7 @@ public class ClassInfo implements Finalizable {
                 cachedClass = new CachedClass(klazz, classInfo);
             }
         } else {
-            if (klazz.getName().charAt(0) == '[')
+            if (klazz.isArray())
               cachedClass = new ArrayCachedClass(klazz, classInfo);
             else if (klazz == Boolean.class) {
                 cachedClass = new BooleanCachedClass(klazz, classInfo, true);

Daniel Sun
Apache Groovy committer

Blog: http://blog.sunlan.me
Twitter: @daniel_sun