Repository: commons-collections
Updated Branches:
  refs/heads/master 45f42120a -> 2fd2a7611


[COLLECTIONS-666] org.apache.commons.collections4.ListUtils.union(List,
List) should pre-allocate result list

Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/commons-collections/commit/2fd2a761
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/2fd2a761
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/2fd2a761

Branch: refs/heads/master
Commit: 2fd2a76110af7ae07712af01708cc00310af64ef
Parents: 45f4212
Author: Gary Gregory <ggreg...@apache.org>
Authored: Sat Dec 30 23:16:21 2017 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Sat Dec 30 23:16:21 2017 -0700

----------------------------------------------------------------------
 src/changes/changes.xml                                      | 3 +++
 src/main/java/org/apache/commons/collections4/ListUtils.java | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-collections/blob/2fd2a761/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a428945..3b75437 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,9 @@
     <action issue="COLLECTIONS-654" dev="ggregory" type="add">
       Add class SortedProperties to sort keys.
     </action>
+    <action issue="COLLECTIONS-666" dev="ggregory" type="update" 
due-to="BELUGA BEHR">
+      org.apache.commons.collections4.ListUtils.union(List, List) should 
pre-allocate result list.
+    </action>
   </release>
   <release version="4.1" date="2015-11-28" description="This is a security and 
minor release.">
     <action issue="COLLECTIONS-508" dev="tn" type="add">

http://git-wip-us.apache.org/repos/asf/commons-collections/blob/2fd2a761/src/main/java/org/apache/commons/collections4/ListUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java 
b/src/main/java/org/apache/commons/collections4/ListUtils.java
index 38e2e8b..4798588 100644
--- a/src/main/java/org/apache/commons/collections4/ListUtils.java
+++ b/src/main/java/org/apache/commons/collections4/ListUtils.java
@@ -159,7 +159,8 @@ public class ListUtils {
      * @throws NullPointerException if either list is null
      */
     public static <E> List<E> union(final List<? extends E> list1, final 
List<? extends E> list2) {
-        final ArrayList<E> result = new ArrayList<>(list1);
+        final ArrayList<E> result = new ArrayList<>(list1.size() + 
list2.size());
+        result.addAll(list1);
         result.addAll(list2);
         return result;
     }

Reply via email to