Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -109,7 +109,7 @@ public static ExecutableImage create(Set<Archive> archives,
}

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 @@ private static ResourcePool generateJImage(ResourcePoolManager allContent,
out.write(bytes, 0, bytes.length);

// write module content
content.stream().forEach((res) -> {
content.forEach((res) -> {
res.write(out);
});

@@ -94,7 +94,7 @@ public static ImagePluginStack parseConfiguration(Jlink.PluginsConfiguration plu
}

List<Plugin> orderedPlugins = new ArrayList<>();
plugins.entrySet().stream().forEach((entry) -> {
plugins.entrySet().forEach((entry) -> {
orderedPlugins.addAll(entry.getValue());
});
Plugin lastSorter = null;
@@ -181,7 +181,7 @@ public ImagePluginStack(ImageBuilder imageBuilder,
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 ResourcePool visitResources(ResourcePoolManager resources)
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);
});

@@ -283,7 +283,7 @@ private Bucket<E>[] createBuckets() {
// 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 @@ private boolean collidedEntries(Bucket<E> bucket, int count) {
}

// Undo the attempted packing.
undo.stream().forEach((i) -> {
undo.forEach((i) -> {
order[i] = null;
});

@@ -143,7 +143,7 @@ private static <T extends Plugin> List<T> getPlugins(Class<T> clazz, ModuleLayer
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;
@@ -47,15 +47,15 @@ private static ModuleDescriptor descriptorOf(ResourcePoolModule mod) {

// 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());

@@ -99,9 +99,8 @@ public void configure(Map<String, String> config) {
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;

@@ -65,7 +65,7 @@ private ResourceFilter(List<String> patterns, boolean exclude) {
throw new UncheckedIOException(ex);
}

lines.stream().forEach((line) -> {
lines.forEach((line) -> {
matchers.add(Utils.getJRTFSPathMatcher(line.trim()));
});
} else {
@@ -311,9 +311,7 @@ private void writeDescriptorReference(DataOutputStream out,
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);