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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 4.2
    • 4.2
    • List
    • 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

            Unassigned Unassigned
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: