Bukama commented on code in PR #2363: URL: https://github.com/apache/maven/pull/2363#discussion_r2100460591
########## src/mdo/java/ImmutableCollections.java: ########## @@ -79,32 +65,7 @@ public int size() { }; static <E> List<E> copy(Collection<E> collection) { - if (collection == null) { - return emptyList(); - } else if (collection instanceof AbstractImmutableList) { - return (List<E>) collection; - } else { - switch (collection.size()) { - case 0: - return emptyList(); - case 1: - return singletonList(collection.iterator().next()); - case 2: - Iterator<E> it = collection.iterator(); - return new List2<>(it.next(), it.next()); - default: - return new ListN<>(collection); - } - } - } - - @SuppressWarnings("unchecked") - static <E> List<E> emptyList() { - return (List<E>) EMPTY_LIST; - } - - static <E> List<E> singletonList(E element) { - return new List1<>(element); + return collection == null ? List.of() : List.copyOf(collection); Review Comment: Why not `Collections.emptyList()`? Does the empty list needs to be mutable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org