commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COLLECTIONS-666) org.apache.commons.collections4.ListUtils.union(List, List) should pre-allocate result list
Date Sun, 31 Dec 2017 06:18:01 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gary Gregory resolved COLLECTIONS-666.
--------------------------------------
       Resolution: Fixed
    Fix Version/s: 4.2

In Git master. Please verify and close.

> org.apache.commons.collections4.ListUtils.union(List, List) should pre-allocate result
list
> -------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-666
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-666
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: List
>    Affects Versions: 4.2
>            Reporter: BELUGA BEHR
>            Priority: Trivial
>             Fix For: 4.2
>
>
> {code}
> public static <E> List<E> union(final List<? extends E> list1, final
List<? extends E> list2) {
>         final ArrayList<E> result = new ArrayList<E>(list1);
>         result.addAll(list2);
>         return result;
> }
> {code}
> Maybe we should create the _result_ list with the size of list1 + list 2, then perform
two add all.  This will prevent the ArrayList from being re-sized on the addAll step.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message