Skip to content

Commit 7b978b6

Browse files
committed
Avoid unnecessary List creation (#382)
1 parent b4e056b commit 7b978b6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

metafacture-json/src/main/java/org/metafacture/json/JsonDecoder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.Arrays;
3535
import java.util.List;
3636
import java.util.stream.Collectors;
37+
import java.util.stream.Stream;
3738

3839
/**
3940
* Decodes a record in JSON format.
@@ -152,7 +153,7 @@ private void processRecord(String record) {
152153
}
153154
}
154155

155-
private List<String> matches(Object obj) {
156+
private Stream<String> matches(Object obj) {
156157
final List<?> records = (obj instanceof List<?>) ? ((List<?>) obj) : Arrays.asList(obj);
157158
return records.stream().map(doc -> {
158159
try {
@@ -161,7 +162,7 @@ private List<String> matches(Object obj) {
161162
e.printStackTrace();
162163
return doc.toString();
163164
}
164-
}).collect(Collectors.toList());
165+
});
165166
}
166167

167168
@Override

0 commit comments

Comments
 (0)