aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Elder2013-10-03 14:49:14 (EDT)
committerGerrit Code Review @ Eclipse.org2013-10-07 12:14:14 (EDT)
commit026eb5f7a7ff3034cfb3c426ad02ba4d4b9a83b5 (patch)
tree2b65cdb60ed811c76e80f52afcd8366fb3ce04d8
parent83fa9c2e1bea835f2530836e6bf202b5f216dd95 (diff)
downloadeclipse.platform.ui-026eb5f7a7ff3034cfb3c426ad02ba4d4b9a83b5.zip
eclipse.platform.ui-026eb5f7a7ff3034cfb3c426ad02ba4d4b9a83b5.tar.gz
eclipse.platform.ui-026eb5f7a7ff3034cfb3c426ad02ba4d4b9a83b5.tar.bz2
bug 373294: Improve startup timerefs/changes/08/17008/4
Avoid HashMap.values.contains() calls by creating a separate set of mapped values. Change-Id: I9c3fa4072af4ef57ee80a18441529721e331e8d9
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java
index dd7ce3c..4a0bdb5 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/E4XMIResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2013 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
@@ -11,8 +11,10 @@
package org.eclipse.e4.ui.internal.workbench;
+import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.WeakHashMap;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -22,6 +24,7 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
public class E4XMIResource extends XMIResourceImpl {
private Map<EObject, String> objectMap = new WeakHashMap<EObject, String>();
+ private Set<String> knownIds = new HashSet<String>();
public E4XMIResource() {
}
@@ -32,6 +35,7 @@ public class E4XMIResource extends XMIResourceImpl {
public void setInternalId(EObject object, String id) {
objectMap.put(object, id);
+ knownIds.add(id);
}
public String getInternalId(EObject object) {
@@ -49,7 +53,7 @@ public class E4XMIResource extends XMIResourceImpl {
private String getUniqueId() {
String id = createId();
- while (objectMap.values().contains(id)) {
+ while (knownIds.contains(id)) {
id = createId();
}
return id;
@@ -63,6 +67,7 @@ public class E4XMIResource extends XMIResourceImpl {
super.setID(eObject, internalId);
}
objectMap.put(eObject, id);
+ knownIds.add(id);
}
super.setID(eObject, id);
}