]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove manual array copy
authorPer-Åke Minborg <minborg@speedment.com>
Fri, 28 Oct 2016 15:39:13 +0000 (08:39 -0700)
committerHenri Sara <hesara@vaadin.com>
Wed, 2 Nov 2016 15:21:30 +0000 (15:21 +0000)
Change-Id: I80b73b653e97904605dc62484a7448f3bfbf721b

server/src/main/java/com/vaadin/data/BeanBinder.java
server/src/main/java/com/vaadin/event/ActionManager.java
server/src/main/java/com/vaadin/event/ListenerMethod.java
server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java
server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java

index b05e24fc9c6071b3559d206114c520220855de52..a2307a51614da6e07aab4abbd1e677acbbd14d11 100644 (file)
@@ -40,6 +40,7 @@ import com.vaadin.server.SerializableBiConsumer;
 import com.vaadin.server.SerializableFunction;
 import com.vaadin.server.SerializablePredicate;
 import com.vaadin.util.ReflectTools;
+import java.util.Arrays;
 
 /**
  * A {@code Binder} subclass specialized for binding <em>beans</em>: classes
@@ -480,9 +481,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> {
         ArrayList<Field> memberFieldInOrder = new ArrayList<>();
 
         while (searchClass != null) {
-            for (Field memberField : searchClass.getDeclaredFields()) {
-                memberFieldInOrder.add(memberField);
-            }
+            memberFieldInOrder.addAll(Arrays.asList(searchClass.getDeclaredFields()));
             searchClass = searchClass.getSuperclass();
         }
         return memberFieldInOrder;
index b221d175117b3dcd82a7d6d54450fb1f812ffbf8..5d9a92e00013a503fdd931eb8457142274b50dab 100644 (file)
@@ -26,6 +26,7 @@ import com.vaadin.server.PaintException;
 import com.vaadin.server.PaintTarget;
 import com.vaadin.server.VariableOwner;
 import com.vaadin.ui.Component;
+import java.util.Arrays;
 
 /**
  * Javadoc TODO
@@ -249,9 +250,7 @@ public class ActionManager
             for (Action.Handler h : actionHandlers) {
                 Action[] as = h.getActions(target, sender);
                 if (as != null) {
-                    for (Action a : as) {
-                        actions.add(a);
-                    }
+                    actions.addAll(Arrays.asList(as));
                 }
             }
         }
index b81ebd28bcd4044855894a84098076b5871209ba..bf80f1e74b92af2ee6b56547f56d67a9178f69f4 100644 (file)
@@ -508,9 +508,7 @@ public class ListenerMethod implements EventListener, Serializable {
                         method.invoke(target, new Object[] { event });
                     } else {
                         final Object[] arg = new Object[arguments.length];
-                        for (int i = 0; i < arg.length; i++) {
-                            arg[i] = arguments[i];
-                        }
+                        System.arraycopy(arguments, 0, arg, 0, arg.length);
                         arg[eventArgumentIndex] = event;
                         method.invoke(target, arg);
                     }
index 29c4c5491d1f238d348a17171c7777ff6af79dc7..a4a4f0ffdff195a690b8fa96510870171af8ccb3 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.logging.Logger;
 
 import com.vaadin.ui.Component;
+import java.util.Arrays;
 
 /**
  * Binder utility that binds member fields of a design class instance to given
@@ -249,10 +250,8 @@ public class FieldBinder implements Serializable {
             Class<?> searchClass) {
         ArrayList<java.lang.reflect.Field> memberFields = new ArrayList<>();
 
-        for (java.lang.reflect.Field memberField : searchClass
-                .getDeclaredFields()) {
-            memberFields.add(memberField);
-        }
+        memberFields.addAll(Arrays.asList(searchClass
+            .getDeclaredFields()));
         return memberFields;
     }
 
index 1d30e413822a048f091cdce233c04a009e64a2ed..865856f79cb734c197e611a8f36c97a1e65328d0 100644 (file)
@@ -30,6 +30,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import com.vaadin.ui.Component;
+import java.util.Arrays;
 
 public class ClassesSerializableTest {
 
@@ -269,9 +270,7 @@ public class ClassesSerializableTest {
         }
 
         String[] split = classpath.split(pathSep);
-        for (String classpathEntry : split) {
-            locations.add(classpathEntry);
-        }
+        locations.addAll(Arrays.asList(split));
 
         return locations;
     }