You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/12/10 12:40:46 UTC
[commons-compress] branch master updated: Use streams to simplify
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 2d716442 Use streams to simplify
2d716442 is described below
commit 2d71644254d7a3955c9bfe7645b00753f9298268
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 10 07:40:42 2022 -0500
Use streams to simplify
---
.../commons/compress/harmony/unpack200/ClassBands.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
index 03ce4feb..f033790c 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/ClassBands.java
@@ -21,6 +21,8 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.compress.harmony.pack200.Codec;
import org.apache.commons.compress.harmony.pack200.Pack200Exception;
@@ -1149,20 +1151,14 @@ public class ClassBands extends BandSet {
}
/**
- * Answer an ArrayList of ArrayLists which hold the code attributes corresponding to all classes in order.
+ * Gets an ArrayList of ArrayLists which hold the code attributes corresponding to all classes in order.
*
* If a class doesn't have any attributes, the corresponding element in this list will be an empty ArrayList.
*
* @return ArrayList
*/
public ArrayList<List<Attribute>> getOrderedCodeAttributes() {
- final ArrayList<List<Attribute>> orderedAttributeList = new ArrayList<>(codeAttributes.length);
- for (List<Attribute> codeAttribute : codeAttributes) {
- final List<Attribute> currentAttributes = new ArrayList<>(codeAttribute.size());
- currentAttributes.addAll(codeAttribute);
- orderedAttributeList.add(currentAttributes);
- }
- return orderedAttributeList;
+ return Stream.of(codeAttributes).map(ArrayList::new).collect(Collectors.toCollection(ArrayList::new));
}
public ArrayList<Attribute>[][] getMethodAttributes() {