8273711: Remove redundant stream() call before forEach in jdk.jlink

Reviewed-by: alanb, psandoz, dfuchs
This commit is contained in:
Andrey Turbanov 2021-10-06 18:17:58 +00:00 committed by Daniel Fuchs
parent f3cedbe928
commit 4e7d7caa0c
9 changed files with 18 additions and 21 deletions

View File

@ -109,7 +109,7 @@ public final class ImageFileCreator {
}
private void readAllEntries(Set<Archive> archives) {
archives.stream().forEach((archive) -> {
archives.forEach((archive) -> {
Map<Boolean, List<Entry>> es;
try (Stream<Entry> entries = archive.entries()) {
es = entries.collect(Collectors.partitioningBy(n -> n.type()
@ -237,7 +237,7 @@ public final class ImageFileCreator {
out.write(bytes, 0, bytes.length);
// write module content
content.stream().forEach((res) -> {
content.forEach((res) -> {
res.write(out);
});

View File

@ -94,7 +94,7 @@ public final class ImagePluginConfiguration {
}
List<Plugin> orderedPlugins = new ArrayList<>();
plugins.entrySet().stream().forEach((entry) -> {
plugins.entrySet().forEach((entry) -> {
orderedPlugins.addAll(entry.getValue());
});
Plugin lastSorter = null;

View File

@ -181,7 +181,7 @@ public final class ImagePluginStack {
this.imageBuilder = Objects.requireNonNull(imageBuilder);
this.lastSorter = lastSorter;
this.plugins.addAll(Objects.requireNonNull(plugins));
plugins.stream().forEach((p) -> {
plugins.forEach((p) -> {
Objects.requireNonNull(p);
if (p instanceof ResourcePrevisitor) {
resourcePrevisitors.add((ResourcePrevisitor) p);
@ -227,13 +227,13 @@ public final class ImagePluginStack {
resources.getStringTable()).resourcePool();
}
PreVisitStrings previsit = new PreVisitStrings();
resourcePrevisitors.stream().forEach((p) -> {
resourcePrevisitors.forEach((p) -> {
p.previsit(resources.resourcePool(), previsit);
});
// Store the strings resulting from the previsit.
List<String> sorted = previsit.getSortedStrings();
sorted.stream().forEach((s) -> {
sorted.forEach((s) -> {
resources.getStringTable().addString(s);
});

View File

@ -283,7 +283,7 @@ public class PerfectHashBuilder<E> {
// Build bucket chains based on key hash. Collisions end up in same chain.
Bucket<E>[] buckets = (Bucket<E>[])Array.newInstance(bucketComponent, count);
map.values().stream().forEach((entry) -> {
map.values().forEach((entry) -> {
int index = (entry.hashCode() & 0x7FFFFFFF) % count;
Bucket<E> bucket = buckets[index];
@ -327,7 +327,7 @@ public class PerfectHashBuilder<E> {
}
// Undo the attempted packing.
undo.stream().forEach((i) -> {
undo.forEach((i) -> {
order[i] = null;
});

View File

@ -143,7 +143,7 @@ public final class PluginRepository {
while (providers.hasNext()) {
factories.add(providers.next());
}
registeredPlugins.values().stream().forEach((fact) -> {
registeredPlugins.values().forEach((fact) -> {
if (clazz.isInstance(fact)) {
@SuppressWarnings("unchecked")
T trans = (T) fact;

View File

@ -47,15 +47,15 @@ final class ResourcePoolConfiguration {
// drop hashes
ModuleDescriptor.Builder builder = ModuleDescriptor.newModule(md.name());
md.requires().stream()
md.requires()
.forEach(builder::requires);
md.exports().stream()
md.exports()
.forEach(builder::exports);
md.opens().stream()
md.opens()
.forEach(builder::opens);
md.uses().stream()
md.uses()
.forEach(builder::uses);
md.provides().stream()
md.provides()
.forEach(builder::provides);
builder.packages(md.packages());

View File

@ -99,9 +99,8 @@ public final class ReleaseInfoPlugin extends AbstractPlugin {
if (keys == null || keys.isEmpty()) {
throw new IllegalArgumentException("No key specified for delete");
}
Utils.parseList(keys).stream().forEach((k) -> {
release.remove(k);
});
Utils.parseList(keys)
.forEach(release::remove);
}
break;

View File

@ -65,7 +65,7 @@ public class ResourceFilter implements Predicate<String> {
throw new UncheckedIOException(ex);
}
lines.stream().forEach((line) -> {
lines.forEach((line) -> {
matchers.add(Utils.getJRTFSPathMatcher(line.trim()));
});
} else {

View File

@ -311,9 +311,7 @@ public class StringSharingPlugin extends AbstractPlugin implements ResourcePrevi
buffers.add(buffer);
}
ByteBuffer bb = ByteBuffer.allocate(l);
buffers.stream().forEach((buf) -> {
bb.put(buf);
});
buffers.forEach(bb::put);
byte[] compressed_indices = bb.array();
byte[] compressed_size = CompressIndexes.
compress(compressed_indices.length);