groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [3/4] groovy git commit: Trivial refactoring: avoid calling `toArray` with pre-sized array parameter
Date Mon, 02 Apr 2018 04:32:38 GMT
Trivial refactoring: avoid calling `toArray` with pre-sized array parameter

(cherry picked from commit ead1ab0)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 5371354017e7db8699b9f8847e1154201b38be67
Parents: e8f3a15
Author: sunlan <sunlan@apache.org>
Authored: Mon Apr 2 11:48:02 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Mon Apr 2 12:32:17 2018 +0800

----------------------------------------------------------------------
 .../groovy/groovy/grape/GrabAnnotationTransformation.java    | 2 +-
 src/main/groovy/groovy/lang/GroovyShell.java                 | 6 +++---
 src/main/groovy/groovy/lang/MetaClassImpl.java               | 2 +-
 src/main/groovy/groovy/util/CharsetToolkit.java              | 2 +-
 src/main/groovy/groovy/util/ObservableMap.java               | 2 +-
 .../java/org/codehaus/groovy/antlr/AntlrParserPlugin.java    | 8 ++++----
 .../codehaus/groovy/ast/decompiled/ClassSignatureParser.java | 2 +-
 .../groovy/ast/decompiled/FormalParameterParser.java         | 4 ++--
 .../codehaus/groovy/ast/decompiled/TypeSignatureParser.java  | 2 +-
 .../org/codehaus/groovy/ast/tools/WideningCategories.java    | 4 ++--
 .../java/org/codehaus/groovy/classgen/InnerClassVisitor.java | 2 +-
 src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java | 2 +-
 .../java/org/codehaus/groovy/control/OptimizerVisitor.java   | 2 +-
 .../control/customizers/builder/CustomizersFactory.java      | 2 +-
 .../java/org/codehaus/groovy/reflection/CachedClass.java     | 2 +-
 .../java/org/codehaus/groovy/runtime/MethodRankHelper.java   | 2 +-
 .../org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java   | 4 ++--
 .../groovy/runtime/metaclass/MetaClassRegistryImpl.java      | 2 +-
 src/main/java/org/codehaus/groovy/tools/DgmConverter.java    | 2 +-
 .../java/org/codehaus/groovy/tools/FileSystemCompiler.java   | 2 +-
 .../java/org/codehaus/groovy/tools/LoaderConfiguration.java  | 2 +-
 src/main/java/org/codehaus/groovy/tools/StringHelper.java    | 2 +-
 .../org/codehaus/groovy/tools/javac/JavacJavaCompiler.java   | 2 +-
 .../groovy/transform/NamedVariantASTTransformation.java      | 2 +-
 .../groovy/transform/TupleConstructorASTTransformation.java  | 2 +-
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java      | 8 ++++----
 .../groovy/transform/stc/TraitTypeCheckingExtension.java     | 2 +-
 .../codehaus/groovy/transform/stc/UnionTypeClassNode.java    | 6 +++---
 .../org/codehaus/groovy/transform/trait/TraitComposer.java   | 4 ++--
 29 files changed, 43 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/groovy/groovy/grape/GrabAnnotationTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/grape/GrabAnnotationTransformation.java b/src/main/groovy/groovy/grape/GrabAnnotationTransformation.java
index e21e608..82f13e7 100644
--- a/src/main/groovy/groovy/grape/GrabAnnotationTransformation.java
+++ b/src/main/groovy/groovy/grape/GrabAnnotationTransformation.java
@@ -373,7 +373,7 @@ public class GrabAnnotationTransformation extends ClassCodeVisitorSupport
implem
             if (systemProperties != null) basicArgs.put(SYSTEM_PROPERTIES_SETTING, systemProperties);
 
             try {
-                Grape.grab(basicArgs, grabMaps.toArray(new Map[grabMaps.size()]));
+                Grape.grab(basicArgs, grabMaps.toArray(new Map[0]));
                 // grab may have added more transformations through new URLs added to classpath,
so do one more scan
                 if (compilationUnit!=null) {
                     ASTTransformationVisitor.addGlobalTransformsAfterGrab(compilationUnit.getASTTransformationsContext());

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/groovy/groovy/lang/GroovyShell.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/GroovyShell.java b/src/main/groovy/groovy/lang/GroovyShell.java
index 4dc51c9..1ac2fc4 100644
--- a/src/main/groovy/groovy/lang/GroovyShell.java
+++ b/src/main/groovy/groovy/lang/GroovyShell.java
@@ -364,7 +364,7 @@ public class GroovyShell extends GroovyObjectSupport {
      * @param args      the command line arguments to pass in
      */
     public Object run(GroovyCodeSource source, List args) throws CompilationFailedException
{
-        return run(source, ((String[]) args.toArray(new String[args.size()])));
+        return run(source, ((String[]) args.toArray(new String[0])));
     }
 
     /**
@@ -385,7 +385,7 @@ public class GroovyShell extends GroovyObjectSupport {
      * @param args      the command line arguments to pass in
      */
     public Object run(URI source, List args) throws CompilationFailedException, IOException
{
-        return run(new GroovyCodeSource(source), ((String[]) args.toArray(new String[args.size()])));
+        return run(new GroovyCodeSource(source), ((String[]) args.toArray(new String[0])));
     }
 
     /**
@@ -406,7 +406,7 @@ public class GroovyShell extends GroovyObjectSupport {
      * @param list     the command line arguments to pass in
      */
     public Object run(final Reader in, final String fileName, List list) throws CompilationFailedException
{
-        return run(in, fileName, (String[]) list.toArray(new String[list.size()]));
+        return run(in, fileName, (String[]) list.toArray(new String[0]));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/groovy/groovy/lang/MetaClassImpl.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/lang/MetaClassImpl.java b/src/main/groovy/groovy/lang/MetaClassImpl.java
index e281567..427bf29 100644
--- a/src/main/groovy/groovy/lang/MetaClassImpl.java
+++ b/src/main/groovy/groovy/lang/MetaClassImpl.java
@@ -189,7 +189,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
             List<MetaMethod> arr = new ArrayList<MetaMethod>();
             arr.addAll(Arrays.asList(metaMethods));
             arr.addAll(Arrays.asList(add));
-            myNewMetaMethods = arr.toArray(new MetaMethod[arr.size()]);
+            myNewMetaMethods = arr.toArray(new MetaMethod[0]);
             additionalMetaMethods = metaMethods;
         }
         else {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/groovy/groovy/util/CharsetToolkit.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/util/CharsetToolkit.java b/src/main/groovy/groovy/util/CharsetToolkit.java
index e127459..fd7893b 100644
--- a/src/main/groovy/groovy/util/CharsetToolkit.java
+++ b/src/main/groovy/groovy/util/CharsetToolkit.java
@@ -414,6 +414,6 @@ public class CharsetToolkit {
      */
     public static Charset[] getAvailableCharsets() {
         Collection collection = Charset.availableCharsets().values();
-        return (Charset[]) collection.toArray(new Charset[collection.size()]);
+        return (Charset[]) collection.toArray(new Charset[0]);
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/groovy/groovy/util/ObservableMap.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/util/ObservableMap.java b/src/main/groovy/groovy/util/ObservableMap.java
index c55d3b1..ed34064 100644
--- a/src/main/groovy/groovy/util/ObservableMap.java
+++ b/src/main/groovy/groovy/util/ObservableMap.java
@@ -113,7 +113,7 @@ public class ObservableMap implements Map {
     }
 
     protected void fireMultiPropertyEvent(List<PropertyEvent> events) {
-        firePropertyEvent(new MultiPropertyEvent(this, (PropertyEvent[]) events.toArray(new
PropertyEvent[events.size()])));
+        firePropertyEvent(new MultiPropertyEvent(this, (PropertyEvent[]) events.toArray(new
PropertyEvent[0])));
     }
 
     protected void fireMultiPropertyEvent(PropertyEvent[] events) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java b/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
index 2af9882..7f76590 100644
--- a/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
+++ b/src/main/java/org/codehaus/groovy/antlr/AntlrParserPlugin.java
@@ -2608,7 +2608,7 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin,
Groovy
     private static void setTypeArgumentsOnMethodCallExpression(MethodCallExpression expression,
                                                         List<GenericsType> typeArgumentList)
{
         if (typeArgumentList != null && !typeArgumentList.isEmpty()) {
-            expression.setGenericsTypes(typeArgumentList.toArray(new GenericsType[typeArgumentList.size()]));
+            expression.setGenericsTypes(typeArgumentList.toArray(new GenericsType[0]));
         }
     }
 
@@ -3022,7 +3022,7 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin,
Groovy
     private ClassNode addTypeArguments(ClassNode basicType, AST node) {
         List<GenericsType> typeArgumentList = getTypeArgumentsList(node);
         // a 0-length type argument list means we face the diamond operator
-        basicType.setGenericsTypes(typeArgumentList.toArray(new GenericsType[typeArgumentList.size()]));
+        basicType.setGenericsTypes(typeArgumentList.toArray(new GenericsType[0]));
         return basicType;
     }
 
@@ -3055,7 +3055,7 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin,
Groovy
             bounds.add(bound);
         }
         if (bounds.isEmpty()) return null;
-        return (ClassNode[]) bounds.toArray(new ClassNode[bounds.size()]);
+        return (ClassNode[]) bounds.toArray(new ClassNode[0]);
     }
 
     protected GenericsType[] makeGenericsType(AST rootNode) {
@@ -3073,7 +3073,7 @@ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin,
Groovy
             ret.add(gt);
             typeParameter = typeParameter.getNextSibling();
         }
-        return (GenericsType[]) ret.toArray(new GenericsType[ret.size()]);
+        return (GenericsType[]) ret.toArray(new GenericsType[0]);
     }
 
     protected ClassNode makeType(AST typeNode) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/ast/decompiled/ClassSignatureParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/ClassSignatureParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/ClassSignatureParser.java
index 2222590..1bfaeb7 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/ClassSignatureParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/ClassSignatureParser.java
@@ -79,6 +79,6 @@ class ClassSignatureParser {
         if (typeParameters.length > 0) {
             classNode.setGenericsTypes(typeParameters);
         }
-        classNode.setInterfaces(interfaces.toArray(new ClassNode[interfaces.size()]));
+        classNode.setInterfaces(interfaces.toArray(new ClassNode[0]));
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
index 3ed8c3f..9f281ab 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/FormalParameterParser.java
@@ -51,7 +51,7 @@ abstract class FormalParameterParser extends SignatureVisitor {
     protected void flushTypeParameter() {
         if (currentTypeParameter != null) {
             ClassNode ref = Java5.configureTypeVariableReference(currentTypeParameter);
-            ClassNode[] boundNodes = parameterBounds.toArray(new ClassNode[parameterBounds.size()]);
+            ClassNode[] boundNodes = parameterBounds.toArray(new ClassNode[0]);
             typeParameters.add(Java5.configureTypeVariableDefinition(ref, boundNodes));
 
             currentTypeParameter = null;
@@ -76,6 +76,6 @@ abstract class FormalParameterParser extends SignatureVisitor {
 
     public GenericsType[] getTypeParameters() {
         flushTypeParameter();
-        return typeParameters.toArray(new GenericsType[typeParameters.size()]);
+        return typeParameters.toArray(new GenericsType[0]);
     }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java b/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
index ae5efb1..5f8f03d 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/TypeSignatureParser.java
@@ -117,7 +117,7 @@ abstract class TypeSignatureParser extends SignatureVisitor {
         }
 
         ClassNode bound = base.getPlainNodeReference();
-        bound.setGenericsTypes(arguments.toArray(new GenericsType[arguments.size()]));
+        bound.setGenericsTypes(arguments.toArray(new GenericsType[0]));
         finished(bound);
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
index 1489a56..712e80b 100644
--- a/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
+++ b/src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
@@ -573,7 +573,7 @@ public class WideningCategories {
                 itcn.remove();
             }
         }
-        ClassNode[] interfaceArray = interfaces.toArray(new ClassNode[interfaces.size()]);
+        ClassNode[] interfaceArray = interfaces.toArray(new ClassNode[0]);
         Arrays.sort(interfaceArray, INTERFACE_CLASSNODE_COMPARATOR);
         type = new LowestUpperBoundClassNode(name, superClass, interfaceArray);
         return type;
@@ -632,7 +632,7 @@ public class WideningCategories {
                         Collections.addAll(asArrayList, genericsTypes);
                     }
                 }
-                setGenericsTypes(asArrayList.toArray(new GenericsType[asArrayList.size()]));
+                setGenericsTypes(asArrayList.toArray(new GenericsType[0]));
             }
             StringBuilder sb = new StringBuilder();
             if (!upper.equals(OBJECT_TYPE)) sb.append(upper.getName());

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/classgen/InnerClassVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/InnerClassVisitor.java b/src/main/java/org/codehaus/groovy/classgen/InnerClassVisitor.java
index 87815a8..56fbc72 100644
--- a/src/main/java/org/codehaus/groovy/classgen/InnerClassVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/InnerClassVisitor.java
@@ -219,7 +219,7 @@ public class InnerClassVisitor extends InnerClassVisitorHelper implements
Opcode
             pField.setOriginType(ClassHelper.getWrapper(var.getOriginType()));
         }
 
-        innerClass.addConstructor(ACC_SYNTHETIC, parameters.toArray(new Parameter[parameters.size()]),
ClassNode.EMPTY_ARRAY, block);
+        innerClass.addConstructor(ACC_SYNTHETIC, parameters.toArray(new Parameter[0]), ClassNode.EMPTY_ARRAY,
block);
     }
 
     private boolean isStaticThis(InnerClassNode innerClass, VariableScope scope) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java b/src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java
index e583ac9..4168fa6 100644
--- a/src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java
+++ b/src/main/java/org/codehaus/groovy/cli/GroovyPosixParser.java
@@ -159,7 +159,7 @@ public class GroovyPosixParser extends Parser
             gobble(iter);
         }
 
-        return (String[]) tokens.toArray(new String[tokens.size()]);
+        return (String[]) tokens.toArray(new String[0]);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/control/OptimizerVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/OptimizerVisitor.java b/src/main/java/org/codehaus/groovy/control/OptimizerVisitor.java
index 6bb343b..24a9c31 100644
--- a/src/main/java/org/codehaus/groovy/control/OptimizerVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/OptimizerVisitor.java
@@ -86,7 +86,7 @@ public class OptimizerVisitor extends ClassCodeExpressionTransformer {
                         newInterfaces.add(classNode);
                     }
                 }
-                node.setInterfaces(newInterfaces.toArray(new ClassNode[newInterfaces.size()]));
+                node.setInterfaces(newInterfaces.toArray(new ClassNode[0]));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/control/customizers/builder/CustomizersFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/customizers/builder/CustomizersFactory.java
b/src/main/java/org/codehaus/groovy/control/customizers/builder/CustomizersFactory.java
index 40ce7e7..ded70d8 100644
--- a/src/main/java/org/codehaus/groovy/control/customizers/builder/CustomizersFactory.java
+++ b/src/main/java/org/codehaus/groovy/control/customizers/builder/CustomizersFactory.java
@@ -52,7 +52,7 @@ public class CustomizersFactory extends AbstractFactory implements PostCompletio
     public Object postCompleteNode(final FactoryBuilderSupport factory, final Object parent,
final Object node) {
         if (node instanceof List) {
             List col = (List) node;
-            return col.toArray(new CompilationCustomizer[col.size()]);
+            return col.toArray(new CompilationCustomizer[0]);
         }
         return node;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
index c4cb542..55d2a43 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
@@ -145,7 +145,7 @@ public class CachedClass {
                 else
                   methods.add(cachedMethod);
             }
-            CachedMethod [] resMethods = methods.toArray(new CachedMethod[methods.size()]);
+            CachedMethod [] resMethods = methods.toArray(new CachedMethod[0]);
             Arrays.sort(resMethods);
 
             final CachedClass superClass = getCachedSuperClass();

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/runtime/MethodRankHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/MethodRankHelper.java b/src/main/java/org/codehaus/groovy/runtime/MethodRankHelper.java
index 295cbe8..689245c 100644
--- a/src/main/java/org/codehaus/groovy/runtime/MethodRankHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/MethodRankHelper.java
@@ -310,7 +310,7 @@ public class MethodRankHelper{
             l.add(rc[index].c);
             index++;
         }
-        return l.toArray(new Constructor[l.size()]);
+        return l.toArray(new Constructor[0]);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
index 47b6f3b..5517087 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
@@ -215,7 +215,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes
{
         }
         if (!traits.isEmpty()) {
             String name = superClass.getName() + "$TraitAdapter";
-            ClassNode cn = new ClassNode(name, ACC_PUBLIC | ACC_ABSTRACT, ClassHelper.OBJECT_TYPE,
traits.toArray(new ClassNode[traits.size()]), null);
+            ClassNode cn = new ClassNode(name, ACC_PUBLIC | ACC_ABSTRACT, ClassHelper.OBJECT_TYPE,
traits.toArray(new ClassNode[0]), null);
             CompilationUnit cu = new CompilationUnit(loader);
             CompilerConfiguration config = new CompilerConfiguration();
             SourceUnit su = new SourceUnit(name + "wrapper", "", config, loader, new ErrorCollector(config));
@@ -341,7 +341,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes
{
             classList.add(GeneratedGroovyProxy.class);
             interfacesSet.add("groovy/lang/GeneratedGroovyProxy");
         }
-        super.visit(V1_5, ACC_PUBLIC, proxyName, signature, BytecodeHelper.getClassInternalName(superClass),
interfacesSet.toArray(new String[interfacesSet.size()]));
+        super.visit(V1_5, ACC_PUBLIC, proxyName, signature, BytecodeHelper.getClassInternalName(superClass),
interfacesSet.toArray(new String[0]));
         visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
         addDelegateFields();
         if (addGroovyObjectSupport) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/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 2914d02..40416a3 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -415,7 +415,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
                     new ArrayList<MetaClassRegistryChangeEventListener>(changeListenerList.size()+nonRemoveableChangeListenerList.size());
             ret.addAll(nonRemoveableChangeListenerList);
             ret.addAll(changeListenerList);
-            return ret.toArray(new MetaClassRegistryChangeEventListener[ret.size()]);
+            return ret.toArray(new MetaClassRegistryChangeEventListener[0]);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/tools/DgmConverter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/tools/DgmConverter.java b/src/main/java/org/codehaus/groovy/tools/DgmConverter.java
index f733227..98d5cf9 100644
--- a/src/main/java/org/codehaus/groovy/tools/DgmConverter.java
+++ b/src/main/java/org/codehaus/groovy/tools/DgmConverter.java
@@ -50,7 +50,7 @@ public class DgmConverter implements Opcodes {
         for (Class aClass : DefaultGroovyMethods.DGM_LIKE_CLASSES) {
             Collections.addAll(cachedMethodsList, ReflectionCache.getCachedClass(aClass).getMethods());
         }
-        final CachedMethod[] cachedMethods = cachedMethodsList.toArray(new CachedMethod[cachedMethodsList.size()]);
+        final CachedMethod[] cachedMethods = cachedMethodsList.toArray(new CachedMethod[0]);
 
         List<GeneratedMetaMethod.DgmMethodRecord> records = new ArrayList<GeneratedMetaMethod.DgmMethodRecord>();
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
index 2e140b2..df10a02 100644
--- a/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/FileSystemCompiler.java
@@ -267,7 +267,7 @@ public class FileSystemCompiler {
         if (errors) {
             return null;
         } else {
-            return fileList.toArray(new String[fileList.size()]);
+            return fileList.toArray(new String[0]);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/tools/LoaderConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/tools/LoaderConfiguration.java b/src/main/java/org/codehaus/groovy/tools/LoaderConfiguration.java
index 4124ddb..de0fb49 100644
--- a/src/main/java/org/codehaus/groovy/tools/LoaderConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/tools/LoaderConfiguration.java
@@ -329,7 +329,7 @@ public class LoaderConfiguration {
      * @see java.net.URLClassLoader
      */
     public URL[] getClassPathUrls() {
-        return classPath.toArray(new URL[classPath.size()]);
+        return classPath.toArray(new URL[0]);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/tools/StringHelper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/tools/StringHelper.java b/src/main/java/org/codehaus/groovy/tools/StringHelper.java
index 279f34e..6f7865f 100644
--- a/src/main/java/org/codehaus/groovy/tools/StringHelper.java
+++ b/src/main/java/org/codehaus/groovy/tools/StringHelper.java
@@ -46,7 +46,7 @@ public class StringHelper {
             }
             first = last;
         }
-        return (String[])tokens.toArray(new String[tokens.size()]);
+        return (String[])tokens.toArray(new String[0]);
     }
 
     private static int scanToken(String s, int pos0) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/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 32fd5d6..e50da83 100644
--- a/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
+++ b/src/main/java/org/codehaus/groovy/tools/javac/JavacJavaCompiler.java
@@ -172,7 +172,7 @@ public class JavacJavaCompiler implements JavaCompiler {
         // files to compile
         paras.addAll(files);
 
-        return paras.toArray(new String[paras.size()]);
+        return paras.toArray(new String[0]);
     }
 
     private Class findJavac(CompilationUnit cu) throws ClassNotFoundException {

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/NamedVariantASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/NamedVariantASTTransformation.java
b/src/main/java/org/codehaus/groovy/transform/NamedVariantASTTransformation.java
index 54008af..905ced8 100644
--- a/src/main/java/org/codehaus/groovy/transform/NamedVariantASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/NamedVariantASTTransformation.java
@@ -152,7 +152,7 @@ public class NamedVariantASTTransformation extends AbstractASTTransformation
{
                                 plusX(new ConstantExpression("Unrecognized namedArgKey: "),
varX(namedArgKey)))
                 ));
 
-        Parameter[] genParamsArray = genParams.toArray(new Parameter[genParams.size()]);
+        Parameter[] genParamsArray = genParams.toArray(new Parameter[0]);
         // TODO account for default params giving multiple signatures
         if (cNode.hasMethod(mNode.getName(), genParamsArray)) {
             addError("Error during " + MY_TYPE_NAME + " processing. Class " + cNode.getNameWithoutPackage()
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
b/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
index 94e31f9..6d49c5d 100644
--- a/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/TupleConstructorASTTransformation.java
@@ -256,7 +256,7 @@ public class TupleConstructorASTTransformation extends AbstractASTTransformation
 
         boolean hasMapCons = AnnotatedNodeUtils.hasAnnotation(cNode, MapConstructorASTTransformation.MY_TYPE);
         int modifiers = getVisibility(anno, cNode, ConstructorNode.class, ACC_PUBLIC);
-        ConstructorNode consNode = new ConstructorNode(modifiers, params.toArray(new Parameter[params.size()]),
ClassNode.EMPTY_ARRAY, body);
+        ConstructorNode consNode = new ConstructorNode(modifiers, params.toArray(new Parameter[0]),
ClassNode.EMPTY_ARRAY, body);
         markAsGenerated(cNode, consNode);
         cNode.addConstructor(consNode);
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 62406f3..77f2e21 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -2144,7 +2144,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                 } else if (arr.size()==1) {
                     result = arr.get(0);
                 } else {
-                    result = new UnionTypeClassNode(arr.toArray(new ClassNode[arr.size()]));
+                    result = new UnionTypeClassNode(arr.toArray(new ClassNode[0]));
                 }
             }
         }
@@ -2831,7 +2831,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
             for (Expression expression : list) {
                 result.add(expression.getText());
             }
-            return result.toArray(new String[result.size()]);
+            return result.toArray(new String[0]);
         }
         throw new IllegalArgumentException("Unexpected options for @ClosureParams:"+options);
     }
@@ -3289,7 +3289,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                         nodes.add(arg);
                     }
                 }
-                return new LowestUpperBoundClassNode(returnType.getName()+"Composed", OBJECT_TYPE,
nodes.toArray(new ClassNode[nodes.size()]));
+                return new LowestUpperBoundClassNode(returnType.getName()+"Composed", OBJECT_TYPE,
nodes.toArray(new ClassNode[0]));
             }
         }
         return returnType;
@@ -4458,7 +4458,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
         Traits.collectSelfTypes(ret, selfTypes);
         if (!selfTypes.isEmpty()) {
             selfTypes.add(ret);
-            ret = new UnionTypeClassNode(selfTypes.toArray(new ClassNode[selfTypes.size()]));
+            ret = new UnionTypeClassNode(selfTypes.toArray(new ClassNode[0]));
         }
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
b/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
index 4a108d9..3138c18 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/TraitTypeCheckingExtension.java
@@ -111,7 +111,7 @@ public class TraitTypeCheckingExtension extends AbstractTypeCheckingExtension
{
         String traitName = decomposed[0];
         String name = decomposed[1];
         LinkedHashSet<ClassNode> traitsAsList = Traits.collectAllInterfacesReverseOrder(receiver,
new LinkedHashSet<ClassNode>());
-        ClassNode[] implementedTraits = traitsAsList.toArray(new ClassNode[traitsAsList.size()]);
+        ClassNode[] implementedTraits = traitsAsList.toArray(new ClassNode[0]);
         ClassNode nextTrait = null;
         for (int i = 0; i < implementedTraits.length - 1; i++) {
             ClassNode implementedTrait = implementedTraits[i];

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java b/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
index c11219e..ac23d81 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
@@ -293,7 +293,7 @@ class UnionTypeClassNode extends ClassNode {
             ClassNode[] interfaces = delegate.getInterfaces();
             if (interfaces != null) Collections.addAll(nodes, interfaces);
         }
-        return nodes.toArray(new ClassNode[nodes.size()]);
+        return nodes.toArray(new ClassNode[0]);
     }
 
     @Override
@@ -328,7 +328,7 @@ class UnionTypeClassNode extends ClassNode {
             ClassNode[] interfaces = delegate.getUnresolvedInterfaces();
             if (interfaces != null) Collections.addAll(nodes, interfaces);
         }
-        return nodes.toArray(new ClassNode[nodes.size()]);
+        return nodes.toArray(new ClassNode[0]);
     }
 
     @Override
@@ -338,7 +338,7 @@ class UnionTypeClassNode extends ClassNode {
             ClassNode[] interfaces = delegate.getUnresolvedInterfaces(useRedirect);
             if (interfaces != null) Collections.addAll(nodes, interfaces);
         }
-        return nodes.toArray(new ClassNode[nodes.size()]);
+        return nodes.toArray(new ClassNode[0]);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/groovy/blob/53713540/src/main/java/org/codehaus/groovy/transform/trait/TraitComposer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/transform/trait/TraitComposer.java b/src/main/java/org/codehaus/groovy/transform/trait/TraitComposer.java
index 18126de..b3bdca2 100644
--- a/src/main/java/org/codehaus/groovy/transform/trait/TraitComposer.java
+++ b/src/main/java/org/codehaus/groovy/transform/trait/TraitComposer.java
@@ -405,7 +405,7 @@ public abstract class TraitComposer {
         }
         if (!modified) return oldTypes;
         if (l.isEmpty()) return null;
-        return l.toArray(new GenericsType[l.size()]);
+        return l.toArray(new GenericsType[0]);
     }
 
     /**
@@ -431,7 +431,7 @@ public abstract class TraitComposer {
             }
         }
         for (MethodNode superForwarder : superForwarders) {
-            doCreateSuperForwarder(targetNode, superForwarder, traits.toArray(new ClassNode[traits.size()]),
genericsSpec);
+            doCreateSuperForwarder(targetNode, superForwarder, traits.toArray(new ClassNode[0]),
genericsSpec);
         }
     }
 


Mime
View raw message