mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less garbage: no new instance on empty collection
This commit is contained in:
@@ -87,6 +87,7 @@ public abstract class JBIterable<E> implements Iterable<E> {
|
||||
public static <E> JBIterable<E> from(@Nullable Iterable<? extends E> iterable) {
|
||||
if (iterable == null) return empty();
|
||||
if (iterable instanceof JBIterable) return (JBIterable<E>)iterable;
|
||||
if (iterable instanceof Collection && ((Collection)iterable).isEmpty()) return empty();
|
||||
return new JBIterable<E>((Iterable<E>)iterable) {
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
|
||||
Reference in New Issue
Block a user