Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-20 13:05:43 -0400
committerLars Vogel2019-06-21 02:59:54 -0400
commitecce9c75ee460f70b993efc93bdc8f8d69c696e2 (patch)
tree374b32aee1f9d1ad991b00e6962c2d6661aa82e8
parentf540c0b4a0d395fb7aa243e1c59364de3f923a35 (diff)
downloadrt.equinox.framework-ecce9c75ee460f70b993efc93bdc8f8d69c696e2.tar.gz
rt.equinox.framework-ecce9c75ee460f70b993efc93bdc8f8d69c696e2.tar.xz
rt.equinox.framework-ecce9c75ee460f70b993efc93bdc8f8d69c696e2.zip
Use addAll, deleteAll instead of looping through a collection
Simplifies reading the code. Change-Id: I3858fbb5778df3d50bbd61d37ba26a66107e5650
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java4
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java3
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java7
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java3
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java9
-rw-r--r--bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java12
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java5
13 files changed, 22 insertions, 47 deletions
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index 71ff90007..f57bc03ee 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -17,6 +17,7 @@ package org.eclipse.osgi.internal.module;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -197,8 +198,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
private <T> List<T> getAll(T[] hostEntries, Map<Long, List<T>> fragmentMap) {
List<T> result = new ArrayList<>(hostEntries.length);
- for (T entry : hostEntries)
- result.add(entry);
+ Collections.addAll(result, hostEntries);
for (ResolverBundle fragment : fragments) {
List<T> fragEntries = fragmentMap.get(fragment.bundleID);
if (fragEntries != null)
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 93b5abc75..90e28d7f4 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -597,8 +597,7 @@ public class ResolverImpl implements Resolver {
return reRefresh; // no new bundles found to refresh
// add the original reRefresh bundles to the set
if (reRefresh != null)
- for (int i = 0; i < reRefresh.length; i++)
- additionalRefresh.add(reRefresh[i]);
+ Collections.addAll(additionalRefresh, reRefresh);
return additionalRefresh.toArray(new BundleDescription[additionalRefresh.size()]);
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
index 4640426ff..a269baecb 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
@@ -16,6 +16,7 @@ package org.eclipse.osgi.internal.resolver;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
@@ -177,8 +178,7 @@ public class StateBuilder {
if (aliasList == null || aliasList.size() == 0)
return genericRequires;
if (genericRequires != null)
- for (int i = 0; i < genericRequires.length; i++)
- aliasList.add(genericRequires[i]);
+ Collections.addAll(aliasList, genericRequires);
return aliasList.toArray(new ManifestElement[aliasList.size()]);
}
@@ -206,8 +206,7 @@ public class StateBuilder {
if (aliasList == null || aliasList.size() == 0)
return genericCapabilities;
if (genericCapabilities != null)
- for (int i = 0; i < genericCapabilities.length; i++)
- aliasList.add(genericCapabilities[i]);
+ Collections.addAll(aliasList, genericCapabilities);
return aliasList.toArray(new ManifestElement[aliasList.size()]);
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
index 5b14c9a48..bb46caa5f 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateHelperImpl.java
@@ -120,8 +120,7 @@ public final class StateHelperImpl implements StateHelper {
Map<String, List<GenericDescription>> generics = getGenericsMap(state, false);
Set<VersionConstraint> result = new HashSet<>();
List<BundleDescription> bundleList = new ArrayList<>(bundles.length);
- for (int i = 0; i < bundles.length; i++)
- bundleList.add(bundles[i]);
+ Collections.addAll(bundleList, bundles);
for (int i = 0; i < bundleList.size(); i++) {
BundleDescription description = bundleList.get(i);
VersionConstraint[] constraints = getUnsatisfiedConstraints(description, hook);
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index f3047ff5a..2f79e5aea 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -619,8 +619,7 @@ public abstract class StateImpl implements State {
return reResolve; // if reResolve length==0 then we want to prevent pending removal
// merge in all removal pending bundles that are not already in the list
List<BundleDescription> result = new ArrayList<>(reResolve.length + removed.length);
- for (int i = 0; i < reResolve.length; i++)
- result.add(reResolve[i]);
+ Collections.addAll(result, reResolve);
for (int i = 0; i < removed.length; i++) {
boolean found = false;
for (int j = 0; j < reResolve.length; j++) {
@@ -756,16 +755,14 @@ public abstract class StateImpl implements State {
ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
if (bundlePackages == null)
continue;
- for (int i = 0; i < bundlePackages.length; i++)
- allExportedPackages.add(bundlePackages[i]);
+ Collections.addAll(allExportedPackages, bundlePackages);
}
for (Iterator<BundleDescription> iter = removalPendings.iterator(); iter.hasNext();) {
BundleDescription bundle = iter.next();
ExportPackageDescription[] bundlePackages = bundle.getSelectedExports();
if (bundlePackages == null)
continue;
- for (int i = 0; i < bundlePackages.length; i++)
- allExportedPackages.add(bundlePackages[i]);
+ Collections.addAll(allExportedPackages, bundlePackages);
}
return allExportedPackages.toArray(new ExportPackageDescription[allExportedPackages.size()]);
}
diff --git a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
index 61b1b32ba..b4b4e9186 100644
--- a/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
+++ b/bundles/org.eclipse.osgi.compatibility.state/src/org/eclipse/osgi/internal/resolver/StateObjectFactoryImpl.java
@@ -121,9 +121,7 @@ public class StateObjectFactoryImpl implements StateObjectFactory {
includeIdentity.add(genericIdentity);
}
if (genericCapabilities != null) {
- for (GenericDescription genericDescription : genericCapabilities) {
- includeIdentity.add(genericDescription);
- }
+ Collections.addAll(includeIdentity, genericCapabilities);
}
if (!includeIdentity.isEmpty()) {
bundle.setGenericCapabilities(includeIdentity.toArray(new GenericDescription[includeIdentity.size()]));
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
index a25ed24f1..3415dad34 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
@@ -1019,9 +1019,7 @@ public class ModuleDatabase {
Map<ModuleRevision, ModuleWiring> wirings = moduleDatabase.wirings;
for (ModuleWiring wiring : wirings.values()) {
Collection<String> substituted = wiring.getSubstitutedNames();
- for (String pkgName : substituted) {
- allStrings.add(pkgName);
- }
+ allStrings.addAll(substituted);
}
// Now persist all the Strings
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index c55afa11e..c48483a2e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -606,9 +606,7 @@ final class ModuleResolver {
this.optionals = new LinkedHashSet<>(unresolved);
if (this.triggersMandatory) {
// do this the hard way because the 'optimization' in removeAll hurts us
- for (ModuleRevision triggerRevision : triggers) {
- this.optionals.remove(triggerRevision);
- }
+ this.optionals.removeAll(triggers);
}
this.wirings = new HashMap<>(wirings);
this.previouslyResolved = new HashSet<>(wirings.keySet());
@@ -1406,9 +1404,7 @@ final class ModuleResolver {
Collection<ModuleRevision> enabledCandidates = new ArrayList<>(unresolved);
hook.filterResolvable(InternalUtils.asListBundleRevision((List<? extends BundleRevision>) enabledCandidates));
// do this the hard way because the 'optimization' in removeAll hurts us
- for (ModuleRevision enabledRevision : enabledCandidates) {
- disabled.remove(enabledRevision);
- }
+ disabled.removeAll(enabledCandidates);
for (ModuleRevision revision : disabled) {
reportBuilder.addEntry(revision, Entry.Type.FILTERED_BY_RESOLVER_HOOK, null);
if (DEBUG_HOOKS) {
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
index 239597afa..11da9b3ff 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/builders/OSGiManifestBuilderFactory.java
@@ -612,9 +612,7 @@ public final class OSGiManifestBuilderFactory {
List<String> classpath = new ArrayList<>();
for (ManifestElement element : classpathElements) {
String[] components = element.getValueComponents();
- for (String component : components) {
- classpath.add(component);
- }
+ Collections.addAll(classpath, components);
}
attributes.put(EquinoxModuleDataNamespace.CAPABILITY_CLASSPATH, classpath);
}
@@ -624,9 +622,7 @@ public final class OSGiManifestBuilderFactory {
if (buddyPolicies != null) {
List<String> policies = new ArrayList<>();
for (ManifestElement element : buddyPolicies) {
- for (String component : element.getValueComponents()) {
- policies.add(component);
- }
+ Collections.addAll(policies, element.getValueComponents());
}
attributes.put(EquinoxModuleDataNamespace.CAPABILITY_BUDDY_POLICY, policies);
}
@@ -636,9 +632,7 @@ public final class OSGiManifestBuilderFactory {
if (registeredBuddies != null) {
List<String> buddies = new ArrayList<>();
for (ManifestElement element : registeredBuddies) {
- for (String component : element.getValueComponents()) {
- buddies.add(component);
- }
+ Collections.addAll(buddies, element.getValueComponents());
}
attributes.put(EquinoxModuleDataNamespace.CAPABILITY_BUDDY_REGISTERED, buddies);
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
index 2c5a22106..94920c0e3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/BundleContextImpl.java
@@ -1095,9 +1095,7 @@ public class BundleContextImpl implements BundleContext, EventDispatcher<Object,
return empty;
}
List<ServiceReference<S>> result = new ArrayList<>(refs.length);
- for (ServiceReference<S> b : refs) {
- result.add(b);
- }
+ Collections.addAll(result, refs);
return result;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
index b0e08c00e..0a3890b9c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/BundleLoader.java
@@ -1106,8 +1106,7 @@ public class BundleLoader extends ModuleLoader {
StringBuilder importSpec = new StringBuilder();
for (ManifestElement dynamicImportElement : packages) {
String[] names = dynamicImportElement.getValueComponents();
- for (String name : names)
- dynamicImports.add(name);
+ Collections.addAll(dynamicImports, names);
if (importSpec.length() > 0) {
importSpec.append(',');
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
index 5e75d8aa3..d9e42d22d 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
@@ -304,8 +304,7 @@ public final class SecurityAdmin implements PermissionAdmin, ConditionalPermissi
synchronized (lock) {
SecurityRow[] rows = condAdminTable.getRows();
List<ConditionalPermissionInfo> vRows = new ArrayList<>(rows.length);
- for (int i = 0; i < rows.length; i++)
- vRows.add(rows[i]);
+ Collections.addAll(vRows, rows);
return Collections.enumeration(vRows);
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
index 70e43c7da..03fea5fe2 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
@@ -23,6 +23,7 @@ import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.container.ModuleCapability;
@@ -167,9 +168,7 @@ public class FrameworkExtensionInstaller {
// must create a copy because paths could be unmodifiable
paths = new ArrayList<>(paths);
String[] devPaths = configuration.getDevClassPath(revision.getSymbolicName());
- for (String devPath : devPaths) {
- paths.add(devPath);
- }
+ Collections.addAll(paths, devPaths);
}
List<File> results = new ArrayList<>(paths.size());
for (String path : paths) {

Back to the top