diff options
author | Matthew Hall | 2010-02-28 07:08:21 +0000 |
---|---|---|
committer | Matthew Hall | 2010-02-28 07:08:21 +0000 |
commit | e1fa351bc7375119190893079af56289b6b37954 (patch) | |
tree | f0983fd22707d89bcaddcafb888b43b7f1139501 /bundles/org.eclipse.core.databinding/src/org/eclipse/core | |
parent | 9f547d7430b9926122e52c245d09896e365317c6 (diff) | |
download | eclipse.platform.ui-e1fa351bc7375119190893079af56289b6b37954.tar.gz eclipse.platform.ui-e1fa351bc7375119190893079af56289b6b37954.tar.xz eclipse.platform.ui-e1fa351bc7375119190893079af56289b6b37954.zip |
FIXED - bug 303847: [Databinding] MapSimpleValueObservableMap#get(Object) is not scaling very well
https://bugs.eclipse.org/bugs/show_bug.cgi?id=303847
Diffstat (limited to 'bundles/org.eclipse.core.databinding/src/org/eclipse/core')
3 files changed, 35 insertions, 21 deletions
diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityMap.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityMap.java index 8f464bf5ad8..b8a15107d89 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityMap.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityMap.java @@ -9,7 +9,7 @@ * Matthew Hall - initial API and implementation (bug 215531) * Matthew Hall - bug 228125 * (through ViewerElementMap.java) - * Matthew Hall - bug 262269 + * Matthew Hall - bugs 262269, 303847 ******************************************************************************/ package org.eclipse.core.internal.databinding; @@ -62,7 +62,7 @@ public class IdentityMap implements Map { } public boolean containsKey(Object key) { - return wrappedMap.containsKey(new IdentityWrapper(key)); + return wrappedMap.containsKey(IdentityWrapper.wrap(key)); } public boolean containsValue(Object value) { @@ -151,8 +151,8 @@ public class IdentityMap implements Map { public boolean remove(Object o) { final Map.Entry unwrappedEntry = (Map.Entry) o; - final IdentityWrapper wrappedKey = new IdentityWrapper( - unwrappedEntry.getKey()); + final IdentityWrapper wrappedKey = IdentityWrapper + .wrap(unwrappedEntry.getKey()); Map.Entry wrappedEntry = new Map.Entry() { public Object getKey() { return wrappedKey; @@ -246,7 +246,7 @@ public class IdentityMap implements Map { } public Object get(Object key) { - return wrappedMap.get(new IdentityWrapper(key)); + return wrappedMap.get(IdentityWrapper.wrap(key)); } public boolean isEmpty() { @@ -269,12 +269,12 @@ public class IdentityMap implements Map { } public boolean contains(Object o) { - return wrappedKeySet.contains(new IdentityWrapper(o)); + return wrappedKeySet.contains(IdentityWrapper.wrap(o)); } public boolean containsAll(Collection c) { for (Iterator iterator = c.iterator(); iterator.hasNext();) - if (!wrappedKeySet.contains(new IdentityWrapper(iterator + if (!wrappedKeySet.contains(IdentityWrapper.wrap(iterator .next()))) return false; return true; @@ -303,14 +303,14 @@ public class IdentityMap implements Map { } public boolean remove(Object o) { - return wrappedKeySet.remove(new IdentityWrapper(o)); + return wrappedKeySet.remove(IdentityWrapper.wrap(o)); } public boolean removeAll(Collection c) { boolean changed = false; for (Iterator iterator = c.iterator(); iterator.hasNext();) - changed |= wrappedKeySet.remove(new IdentityWrapper( - iterator.next())); + changed |= wrappedKeySet.remove(IdentityWrapper + .wrap(iterator.next())); return changed; } @@ -367,20 +367,20 @@ public class IdentityMap implements Map { } public Object put(Object key, Object value) { - return wrappedMap.put(new IdentityWrapper(key), value); + return wrappedMap.put(IdentityWrapper.wrap(key), value); } public void putAll(Map other) { for (Iterator iterator = other.entrySet().iterator(); iterator .hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); - wrappedMap.put(new IdentityWrapper(entry.getKey()), entry + wrappedMap.put(IdentityWrapper.wrap(entry.getKey()), entry .getValue()); } } public Object remove(Object key) { - return wrappedMap.remove(new IdentityWrapper(key)); + return wrappedMap.remove(IdentityWrapper.wrap(key)); } public int size() { diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentitySet.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentitySet.java index 4aa77138e5b..4fc37043e7f 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentitySet.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentitySet.java @@ -9,7 +9,7 @@ * Matthew Hall - initial API and implementation (bug 215531) * Matthew Hall - bug 124684 * (through ViewerElementSet.java) - * Matthew Hall - bug 262269 + * Matthew Hall - bugs 262269, 303847 ******************************************************************************/ package org.eclipse.core.internal.databinding; @@ -54,13 +54,13 @@ public class IdentitySet implements Set { } public boolean add(Object o) { - return wrappedSet.add(new IdentityWrapper(o)); + return wrappedSet.add(IdentityWrapper.wrap(o)); } public boolean addAll(Collection c) { boolean changed = false; for (Iterator iterator = c.iterator(); iterator.hasNext();) - changed |= wrappedSet.add(new IdentityWrapper(iterator.next())); + changed |= wrappedSet.add(IdentityWrapper.wrap(iterator.next())); return changed; } @@ -69,12 +69,12 @@ public class IdentitySet implements Set { } public boolean contains(Object o) { - return wrappedSet.contains(new IdentityWrapper(o)); + return wrappedSet.contains(IdentityWrapper.wrap(o)); } public boolean containsAll(Collection c) { for (Iterator iterator = c.iterator(); iterator.hasNext();) - if (!wrappedSet.contains(new IdentityWrapper(iterator.next()))) + if (!wrappedSet.contains(IdentityWrapper.wrap(iterator.next()))) return false; return true; } @@ -101,7 +101,7 @@ public class IdentitySet implements Set { } public boolean remove(Object o) { - return wrappedSet.remove(new IdentityWrapper(o)); + return wrappedSet.remove(IdentityWrapper.wrap(o)); } public boolean removeAll(Collection c) { diff --git a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityWrapper.java b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityWrapper.java index 978c99627a9..7122a913f10 100644 --- a/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityWrapper.java +++ b/bundles/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/IdentityWrapper.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Daniel Kruegler - bug 137435 + * Matthew Hall - bug 303847 ******************************************************************************/ package org.eclipse.core.internal.databinding; @@ -21,15 +22,28 @@ package org.eclipse.core.internal.databinding; * */ public class IdentityWrapper { + + private static final IdentityWrapper NULL_WRAPPER = new IdentityWrapper( + null); + + /** + * @param obj + * the object to wrap + * @return an IdentityWrapper wrapping the specified object + */ + public static IdentityWrapper wrap(Object obj) { + return obj == null ? NULL_WRAPPER : new IdentityWrapper(obj); + } + final Object o; /** * @param o */ - public IdentityWrapper(Object o) { + private IdentityWrapper(Object o) { this.o = o; } - + /** * @return the unwrapped object */ |