Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 131470 Details for
Bug 269185
osgi plug-ins hold on to too much memory
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
remove Object[1] arrays
269185.txt (text/plain), 5.90 KB, created by
Thomas Watson
on 2009-04-09 18:06:10 EDT
(
hide
)
Description:
remove Object[1] arrays
Filename:
MIME Type:
Creator:
Thomas Watson
Created:
2009-04-09 18:06:10 EDT
Size:
5.90 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.osgi >Index: resolver/src/org/eclipse/osgi/internal/module/MappedList.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/MappedList.java,v >retrieving revision 1.2 >diff -u -r1.2 MappedList.java >--- resolver/src/org/eclipse/osgi/internal/module/MappedList.java 15 Jul 2008 17:56:59 -0000 1.2 >+++ resolver/src/org/eclipse/osgi/internal/module/MappedList.java 9 Apr 2009 22:01:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -22,18 +22,17 @@ > protected HashMap internal = new HashMap(); > > public void put(Object key, Object value) { >- Object[] existing = (Object[]) internal.get(key); >+ Object existing = internal.get(key); > if (existing == null) { >- existing = new Object[1]; // be optimistic; start small >- existing[0] = value; >- internal.put(key, existing); >+ internal.put(key, value); > } else { >+ Object[] existingValues = existing.getClass().isArray() ? (Object[]) existing : new Object[] {existing}; > // insert the new value >- int index = insertionIndex(existing, value); >- Object[] newValues = new Object[existing.length + 1]; >- System.arraycopy(existing, 0, newValues, 0, index); >+ int index = insertionIndex(existingValues, value); >+ Object[] newValues = new Object[existingValues.length + 1]; >+ System.arraycopy(existingValues, 0, newValues, 0, index); > newValues[index] = value; >- System.arraycopy(existing, index, newValues, index + 1, existing.length - index); >+ System.arraycopy(existingValues, index, newValues, index + 1, existingValues.length - index); > internal.put(key, newValues); // overwrite the old values in the map > } > } >@@ -56,8 +55,10 @@ > > // gets all values with the specified and optionally removes them > private Object[] get(Object key, boolean remove) { >- Object[] result = (Object[]) (remove ? internal.remove(key) : internal.get(key)); >- return result == null ? new Object[0] : result; >+ Object result = remove ? internal.remove(key) : internal.get(key); >+ if (result != null && result.getClass().isArray()) >+ return (Object[]) result; >+ return result == null ? new Object[0] : new Object[] {result}; > } > > // returns the number of keyed lists >@@ -72,9 +73,13 @@ > ArrayList results = new ArrayList(getSize()); > Iterator iter = internal.values().iterator(); > while (iter.hasNext()) { >- Object[] values = (Object[]) iter.next(); >- for (int i = 0; i < values.length; i++) >- results.add(values[i]); >+ Object value = iter.next(); >+ if (value.getClass().isArray()) { >+ Object[] values = (Object[]) iter.next(); >+ for (int i = 0; i < values.length; i++) >+ results.add(values[i]); >+ } else >+ results.add(value); > } > return results.toArray(); > } >Index: resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java,v >retrieving revision 1.12 >diff -u -r1.12 VersionHashMap.java >--- resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java 15 Jul 2008 17:56:59 -0000 1.12 >+++ resolver/src/org/eclipse/osgi/internal/module/VersionHashMap.java 9 Apr 2009 22:01:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2008 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -42,20 +42,28 @@ > } > > private VersionSupplier contains(VersionSupplier vs, boolean remove) { >- Object[] existing = (Object[]) internal.get(vs.getName()); >+ Object existing = internal.get(vs.getName()); > if (existing == null) > return null; >- for (int i = 0; i < existing.length; i++) >- if (existing[i] == vs) { >+ if (existing == vs) { >+ if (remove) >+ internal.remove(vs.getName()); >+ return vs; >+ } >+ if (!existing.getClass().isArray()) >+ return null; >+ Object[] existingValues = (Object[]) existing; >+ for (int i = 0; i < existingValues.length; i++) >+ if (existingValues[i] == vs) { > if (remove) { >- if (existing.length == 1) { >- internal.remove(vs.getName()); >+ if (existingValues.length == 2) { >+ internal.put(vs.getName(), existingValues[i == 0 ? 1 : 0]); > return vs; > } >- Object[] newExisting = new Object[existing.length - 1]; >- System.arraycopy(existing, 0, newExisting, 0, i); >- if (i + 1 < existing.length) >- System.arraycopy(existing, i + 1, newExisting, i, existing.length - i - 1); >+ Object[] newExisting = new Object[existingValues.length - 1]; >+ System.arraycopy(existingValues, 0, newExisting, 0, i); >+ if (i + 1 < existingValues.length) >+ System.arraycopy(existingValues, i + 1, newExisting, i, existingValues.length - i - 1); > internal.put(vs.getName(), newExisting); > } > return vs; >@@ -76,10 +84,10 @@ > // from the resolved bundles are ahead of those from unresolved bundles > void reorder() { > for (Iterator it = internal.values().iterator(); it.hasNext();) { >- Object[] existing = (Object[]) it.next(); >- if (existing.length <= 1) >+ Object existing = it.next(); >+ if (!existing.getClass().isArray()) > continue; >- Arrays.sort(existing, this); >+ Arrays.sort((Object[]) existing, this); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 269185
:
129209
|
129381
|
129382
| 131470 |
131522