Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-08-10 12:11:06 -0400
committerThomas Watson2006-08-10 12:11:06 -0400
commitb26e2fa07f774e96234795ef92e0873ae53dcc6f (patch)
tree6add4b6750ba1cf6ce4dd3c71005bd4005e96bde
parent3714425e3eab7d339150f1ea3855753705318f0b (diff)
downloadrt.equinox.framework-b26e2fa07f774e96234795ef92e0873ae53dcc6f.tar.gz
rt.equinox.framework-b26e2fa07f774e96234795ef92e0873ae53dcc6f.tar.xz
rt.equinox.framework-b26e2fa07f774e96234795ef92e0873ae53dcc6f.zip
Bug 152900 StateReader uses ArrayList.contains() taking 4% of all method calls
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java16
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java10
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java16
3 files changed, 18 insertions, 24 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
index e846afbc4..ee45d3ce2 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
@@ -350,21 +350,23 @@ public class BundleDescriptionImpl extends BaseDescriptionImpl implements Bundle
dependencies = null;
}
- protected void addDependencies(BaseDescription[] newDependencies) {
+ protected void addDependencies(BaseDescription[] newDependencies, boolean checkDups) {
if (newDependencies == null)
return;
+ if (!checkDups && dependencies == null)
+ dependencies = new ArrayList(newDependencies.length);
for (int i = 0; i < newDependencies.length; i++) {
- addDependency((BaseDescriptionImpl) newDependencies[i]);
+ addDependency((BaseDescriptionImpl) newDependencies[i], checkDups);
}
}
- protected synchronized void addDependency(BaseDescriptionImpl dependency) {
+ protected synchronized void addDependency(BaseDescriptionImpl dependency, boolean checkDups) {
BundleDescriptionImpl bundle = (BundleDescriptionImpl) dependency.getSupplier();
if (bundle == this)
return;
if (dependencies == null)
dependencies = new ArrayList(10);
- if (!dependencies.contains(bundle)) {
+ if (!checkDups || !dependencies.contains(bundle)) {
bundle.addDependent(this);
dependencies.add(bundle);
}
@@ -397,8 +399,8 @@ public class BundleDescriptionImpl extends BaseDescriptionImpl implements Bundle
protected synchronized void addDependent(BundleDescription dependent) {
if (dependents == null)
dependents = new ArrayList(10);
- if (!dependents.contains(dependent))
- dependents.add(dependent);
+ // no need to check for duplicates here; this is only called in addDepenency which already checks for dups.
+ dependents.add(dependent);
}
protected synchronized void removeDependent(BundleDescription dependent) {
@@ -457,7 +459,7 @@ public class BundleDescriptionImpl extends BaseDescriptionImpl implements Bundle
synchronized void addDynamicResolvedImport(ExportPackageDescriptionImpl result) {
// mark the dependency
- addDependency(result);
+ addDependency(result, true);
// add the export to the list of the resolvedImports
checkLazyData();
if (lazyData.resolvedImports == null) {
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index 2fed95a99..d6ba5059b 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -255,7 +255,7 @@ public abstract class StateImpl implements State {
if (hosts != null) {
hostSpec.setHosts(hosts);
for (int i = 0; i < hosts.length; i++)
- ((BundleDescriptionImpl) hosts[i]).addDependency(bundle);
+ ((BundleDescriptionImpl) hosts[i]).addDependency(bundle, true);
}
}
@@ -263,9 +263,9 @@ public abstract class StateImpl implements State {
bundle.setResolvedRequires(resolvedRequires);
bundle.setResolvedImports(resolvedImports);
- bundle.addDependencies(hosts);
- bundle.addDependencies(resolvedRequires);
- bundle.addDependencies(resolvedImports);
+ bundle.addDependencies(hosts, true);
+ bundle.addDependencies(resolvedRequires, true);
+ bundle.addDependencies(resolvedImports, true);
// add dependecies for generics
GenericSpecification[] genericRequires = bundle.getGenericRequires();
if (genericRequires.length > 0) {
@@ -276,7 +276,7 @@ public abstract class StateImpl implements State {
for (int j = 0; j < suppliers.length; j++)
genericSuppliers.add(suppliers[j]);
}
- bundle.addDependencies((BaseDescription[]) genericSuppliers.toArray(new BaseDescription[genericSuppliers.size()]));
+ bundle.addDependencies((BaseDescription[]) genericSuppliers.toArray(new BaseDescription[genericSuppliers.size()]), true);
}
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
index 3a12206a3..f0e64e55a 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
@@ -204,24 +204,16 @@ class StateReader {
result.setStateBit(BundleDescriptionImpl.DYNAMIC_FRAGMENTS, in.readBoolean());
result.setHost(readHostSpec(in));
- // set the bundle dependencies from imports and requires.
+ // set the bundle dependencies from imports and requires and hosts.
int numDeps = in.readInt();
if (numDeps > 0) {
BundleDescription[] deps = new BundleDescription[numDeps];
for (int i = 0; i < numDeps; i++)
deps[i] = readBundleDescription(in);
- result.addDependencies(deps);
- }
- // set the dependencies between fragment and hosts.
- HostSpecificationImpl hostSpec = (HostSpecificationImpl) result.getHost();
- if (hostSpec != null) {
- BundleDescription[] hosts = hostSpec.getHosts();
- if (hosts != null) {
- for (int i = 0; i < hosts.length; i++)
- ((BundleDescriptionImpl) hosts[i]).addDependency(result);
- result.addDependencies(hosts);
- }
+ result.addDependencies(deps, false); // no need to check dups; we already know there are none when we resolved (bug 152900)
}
+ // No need to set the dependencies between fragment and hosts; that was already done in the above loop (bug 152900)
+
// the rest is lazy loaded data
result.setFullyLoaded(false);
return result;

Back to the top