Skip to content

Commit 31922e7

Browse files
agrievechromeos-ci-prod
authored andcommitted
Android: Remove ~50% of Java stream() usage.
Usage is against style guide, and this CL shows size savings from avoiding them (and arguable more readable in many cases). Bug: 344943957 Change-Id: I101d38afd3e1fb0d981ab5cb4d8032de4b72926a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5958767 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Owners-Override: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Cr-Commit-Position: refs/heads/main@{#1375427} CrOS-Libchrome-Original-Commit: 62574d3dbe1a961a4fcb1be6f50667daa62a8f08
1 parent 4f2b2c1 commit 31922e7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

base/android/java/src/org/chromium/base/CollectionUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,13 @@ public static <T> List<T> strengthen(Collection<WeakReference<T>> weakRefs) {
9191
}
9292
return ret;
9393
}
94+
95+
/** Flattens a collection of collections. */
96+
public static <T> List<T> flatten(Collection<? extends Collection<T>> input) {
97+
List<T> ret = new ArrayList<>();
98+
for (Collection<T> inner : input) {
99+
ret.addAll(inner);
100+
}
101+
return ret;
102+
}
94103
}

0 commit comments

Comments
 (0)