Repository: groovy
Updated Branches:
  refs/heads/master b8a52eb30 -> 87ff616f7


Trivial refactoring: avoid redundant array creation


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

Branch: refs/heads/master
Commit: 87ff616f702855584fb44396d3b8dbeed420c635
Parents: b8a52eb
Author: danielsun1106 <realblue...@hotmail.com>
Authored: Tue Feb 20 03:06:25 2018 +0800
Committer: danielsun1106 <realblue...@hotmail.com>
Committed: Tue Feb 20 03:06:25 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/runtime/DefaultGroovyMethods.java    | 8 ++++----
 .../org/codehaus/groovy/runtime/SocketGroovyMethods.java     | 4 ++--
 .../groovy/runtime/metaclass/MetaClassRegistryImpl.java      | 2 +-
 src/main/java/org/codehaus/groovy/tools/GroovyStarter.java   | 2 +-
 .../org/codehaus/groovy/tools/javac/JavacJavaCompiler.java   | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/87ff616f/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 
b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index e5025df..8b591f7 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -5854,7 +5854,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     // internal helper method
     protected static <T, K, V> T 
callClosureForMapEntry(@ClosureParams(value=FromString.class, 
options={"K,V","Map.Entry<K,V>"}) Closure<T> closure, Map.Entry<K,V> entry) {
         if (closure.getMaximumNumberOfParameters() == 2) {
-            return closure.call(new Object[]{entry.getKey(), 
entry.getValue()});
+            return closure.call(entry.getKey(), entry.getValue());
         }
         return closure.call(entry);
     }
@@ -5862,7 +5862,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     // internal helper method
     protected static <T> T 
callClosureForLine(@ClosureParams(value=FromString.class, 
options={"String","String,Integer"}) Closure<T> closure, String line, int 
counter) {
         if (closure.getMaximumNumberOfParameters() == 2) {
-            return closure.call(new Object[]{line, counter});
+            return closure.call(line, counter);
         }
         return closure.call(line);
     }
@@ -5870,10 +5870,10 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     // internal helper method
     protected static <T, K, V> T 
callClosureForMapEntryAndCounter(@ClosureParams(value=FromString.class, 
options={"K,V,Integer", "K,V","Map.Entry<K,V>"}) Closure<T> closure, 
Map.Entry<K,V> entry, int counter) {
         if (closure.getMaximumNumberOfParameters() == 3) {
-            return closure.call(new Object[]{entry.getKey(), entry.getValue(), 
counter});
+            return closure.call(entry.getKey(), entry.getValue(), counter);
         }
         if (closure.getMaximumNumberOfParameters() == 2) {
-            return closure.call(new Object[]{entry, counter});
+            return closure.call(entry, counter);
         }
         return closure.call(entry);
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/87ff616f/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java 
b/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
index 6582485..ded99e5 100644
--- a/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/SocketGroovyMethods.java
@@ -62,7 +62,7 @@ public class SocketGroovyMethods extends 
DefaultGroovyMethodsSupport {
         InputStream input = socket.getInputStream();
         OutputStream output = socket.getOutputStream();
         try {
-            T result = closure.call(new Object[]{input, output});
+            T result = closure.call(input, output);
 
             InputStream temp1 = input;
             input = null;
@@ -95,7 +95,7 @@ public class SocketGroovyMethods extends 
DefaultGroovyMethodsSupport {
         ObjectOutputStream oos = new ObjectOutputStream(output);
         ObjectInputStream ois = new ObjectInputStream(input);
         try {
-            T result = closure.call(new Object[]{ois, oos});
+            T result = closure.call(ois, oos);
 
             InputStream temp1 = ois;
             ois = null;

http://git-wip-us.apache.org/repos/asf/groovy/blob/87ff616f/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
 
b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
index 88b7351..ff33081 100644
--- 
a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ 
b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -187,7 +187,7 @@ public class MetaClassRegistryImpl implements 
MetaClassRegistry{
     private void installMetaClassCreationHandle() {
            try {
                final Class customMetaClassHandle = 
Class.forName("groovy.runtime.metaclass.CustomMetaClassCreationHandle");
-               final Constructor customMetaClassHandleConstructor = 
customMetaClassHandle.getConstructor(new Class[]{});
+               final Constructor customMetaClassHandleConstructor = 
customMetaClassHandle.getConstructor();
                  this.metaClassCreationHandle = 
(MetaClassCreationHandle)customMetaClassHandleConstructor.newInstance();
            } catch (final ClassNotFoundException e) {
                this.metaClassCreationHandle = new MetaClassCreationHandle();

http://git-wip-us.apache.org/repos/asf/groovy/blob/87ff616f/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java 
b/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
index d4799f4..141ad00 100644
--- a/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
+++ b/src/main/java/org/codehaus/groovy/tools/GroovyStarter.java
@@ -102,7 +102,7 @@ public class GroovyStarter {
         Method m=null;
         try {
             Class c = loader.loadClass(lc.getMainClass());
-            m = c.getMethod("main", new Class[]{String[].class});
+            m = c.getMethod("main", String[].class);
         } catch (ClassNotFoundException e1) {
             exit(e1);
         } catch (SecurityException e2) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/87ff616f/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java 
b/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
index bfed227..32fd5d6 100644
--- a/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
@@ -58,14 +58,14 @@ public class JavacJavaCompiler implements JavaCompiler {
             Class javac = findJavac(cu);
             Method method = null;
             try {
-                method = javac.getMethod("compile", new 
Class[]{String[].class, PrintWriter.class});
+                method = javac.getMethod("compile", String[].class, 
PrintWriter.class);
                 javacOutput = new StringBuilderWriter();
                 PrintWriter writer = new PrintWriter(javacOutput);
                 Object ret = method.invoke(null, javacParameters, writer);
                 javacReturnValue = (Integer) ret;
             } catch (NoSuchMethodException e) { }
             if (method == null) {
-                method = javac.getMethod("compile", new 
Class[]{String[].class});
+                method = javac.getMethod("compile", String[].class);
                 Object ret = method.invoke(null, new 
Object[]{javacParameters});
                 javacReturnValue = (Integer) ret;
             }

Reply via email to