Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-666

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

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 4.2
    • Fix Version/s: 4.2
    • Component/s: List
    • Labels:
      None

      Description

      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;
      }
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              belugabehr David Mollitor

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment