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] [Updated] (COLLECTIONS-666) org.apache.commons.collections4.ListUtils.union(List, List) should pre-allocate result list
Date Sun, 31 Dec 2017 06:16:00 GMT

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

Gary Gregory updated COLLECTIONS-666:
-------------------------------------
    Summary: org.apache.commons.collections4.ListUtils.union(List, List) should pre-allocate
result list  (was: org.apache.commons.collections4.ListUtils.union(List<? extends E>,
List<? extends E>) should pre-allocate result list)

> 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
>
> {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