laurentgo commented on a change in pull request #11063:
URL: https://github.com/apache/arrow/pull/11063#discussion_r700668610
##########
File path:
java/memory/memory-core/src/main/java/org/apache/arrow/util/Collections2.java
##########
@@ -46,23 +45,55 @@ private Collections2() {}
* Converts the iterable into a new {@link List}.
*/
public static <T> List<T> toList(Iterable<T> iterable) {
- return StreamSupport.stream(iterable.spliterator(),
false).collect(Collectors.toList());
+ if (iterable instanceof Collection<?>) {
+ // If iterable is a collection, take advantage of it for a more
efficient copy
+ return new ArrayList<T>((Collection<T>) iterable);
+ }
+ return toList(iterable.iterator());
}
+ /**
+ * Converts the iterable into a new immutable {@link List}.
+ */
+ public static <T> List<T> toImmutableList(Iterable<T> iterable) {
+ return Collections.unmodifiableList(toList(iterable));
Review comment:
Not to knowledge
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]