Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32697552 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Minor optimization for CollectionUtils.mapNotNull"

parents e7a47ab0 72b56168
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -138,14 +138,14 @@ public class CollectionUtils {
    public static @NonNull <I, O> List<O> mapNotNull(@Nullable List<I> cur,
            Function<? super I, ? extends O> f) {
        if (isEmpty(cur)) return Collections.emptyList();
        final ArrayList<O> result = new ArrayList<>();
        List<O> result = null;
        for (int i = 0; i < cur.size(); i++) {
            O transformed = f.apply(cur.get(i));
            if (transformed != null) {
                result.add(transformed);
                result = add(result, transformed);
            }
        }
        return result;
        return emptyIfNull(result);
    }

    /**