Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2008-07-16 18:00:47 +0000
committerThomas Watson2008-07-16 18:00:47 +0000
commit2c2e9777a85ecc8b6868102278d74a87a96a8ada (patch)
tree1dad1a56b072ee6b7e3caf877066ee35abe8a631
parent7f9e32a7ab863d0d8d84d10c95518d77772b6077 (diff)
downloadrt.equinox.framework-2c2e9777a85ecc8b6868102278d74a87a96a8ada.tar.gz
rt.equinox.framework-2c2e9777a85ecc8b6868102278d74a87a96a8ada.tar.xz
rt.equinox.framework-2c2e9777a85ecc8b6868102278d74a87a96a8ada.zip
Bug 240933 CU attachment expensive due to large number of equal capabilities
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
index 142461eb2..c782ee053 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java
@@ -25,6 +25,28 @@ public class VersionHashMap extends MappedList implements Comparator {
Arrays.sort(values, this);
}
+ public void put(Object key, Object value) {
+ Object[] existing = (Object[]) internal.get(key);
+ if (existing == null) {
+ existing = new Object[1]; // be optimistic; start small
+ existing[0] = value;
+ internal.put(key, existing);
+ } else {
+ // insert the new value maintaining sort order.
+ Object[] newValues = new Object[existing.length + 1];
+ int index = existing.length;
+ if (compare(existing[existing.length - 1], value) > 0) {
+ index = Arrays.binarySearch(existing, value, this);
+ if (index < 0)
+ index = -index - 1;
+ }
+ System.arraycopy(existing, 0, newValues, 0, index);
+ newValues[index] = value;
+ System.arraycopy(existing, index, newValues, index + 1, existing.length - index);
+ internal.put(key, newValues); // overwrite the old values in the map
+ }
+ }
+
public void put(VersionSupplier[] versionSuppliers) {
for (int i = 0; i < versionSuppliers.length; i++)
put(versionSuppliers[i].getName(), versionSuppliers[i]);

Back to the top