|
17 | 17 | import java.io.File; |
18 | 18 | import java.io.IOException; |
19 | 19 | import java.util.HashMap; |
20 | | -import java.util.Map.Entry; |
21 | 20 |
|
22 | 21 | import org.eclipse.core.runtime.CoreException; |
23 | 22 | import org.eclipse.core.runtime.IProgressMonitor; |
@@ -66,7 +65,10 @@ public abstract class AbstractBundleContainer extends PlatformObject implements |
66 | 65 | */ |
67 | 66 | private String[] fVMArgs; |
68 | 67 |
|
69 | | - static private HashMap<AbstractBundleContainer, String[]> hash = new HashMap<>(); |
| 68 | + /** |
| 69 | + * Cache for VM arguments to avoid repeated expensive resolution |
| 70 | + */ |
| 71 | + private static final HashMap<AbstractBundleContainer, String[]> fVMArgsCache = new HashMap<>(); |
70 | 72 |
|
71 | 73 | /** |
72 | 74 | * Resolves any string substitution variables in the given text returning |
@@ -223,11 +225,12 @@ protected void clearResolutionStatus() { |
223 | 225 |
|
224 | 226 | @Override |
225 | 227 | public String[] getVMArguments() { |
226 | | - for (Entry<AbstractBundleContainer, String[]> entry : hash.entrySet()) { |
227 | | - if (entry.getKey().equals(this)) { |
228 | | - return entry.getValue(); |
229 | | - } |
| 228 | + // Check cache first for faster lookup |
| 229 | + String[] cachedArgs = fVMArgsCache.get(this); |
| 230 | + if (cachedArgs != null) { |
| 231 | + return cachedArgs; |
230 | 232 | } |
| 233 | + |
231 | 234 | String FWK_ADMIN_EQ = "org.eclipse.equinox.frameworkadmin.equinox"; //$NON-NLS-1$ |
232 | 235 | if (fVMArgs == null) { |
233 | 236 | try { |
@@ -261,10 +264,10 @@ public String[] getVMArguments() { |
261 | 264 |
|
262 | 265 | } |
263 | 266 | if (fVMArgs == null || fVMArgs.length == 0) { |
264 | | - hash.put(this, null); |
| 267 | + fVMArgsCache.put(this, null); |
265 | 268 | return null; |
266 | 269 | } |
267 | | - hash.put(this, fVMArgs); |
| 270 | + fVMArgsCache.put(this, fVMArgs); |
268 | 271 | return fVMArgs; |
269 | 272 | } |
270 | 273 |
|
|
0 commit comments