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 180075 Details for
Bug 326790
Performance Regression for org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Performance improvement to CopyOnWriteIdentityMap for iterating over entry set
bug326790-patch.txt (text/plain), 5.57 KB, created by
BJ Hargrave
on 2010-10-01 13:20:29 EDT
(
hide
)
Description:
Performance improvement to CopyOnWriteIdentityMap for iterating over entry set
Filename:
MIME Type:
Creator:
BJ Hargrave
Created:
2010-10-01 13:20:29 EDT
Size:
5.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.osgi >Index: core/framework/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java,v >retrieving revision 1.6 >diff -u -r1.6 CopyOnWriteIdentityMap.java >--- core/framework/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java 8 Sep 2010 17:56:32 -0000 1.6 >+++ core/framework/org/eclipse/osgi/framework/eventmgr/CopyOnWriteIdentityMap.java 1 Oct 2010 17:16:11 -0000 >@@ -330,7 +330,7 @@ > * The set and the entries returned by the set cannot be modified. > */ > public Set<Map.Entry<K, V>> entrySet() { >- return new EntrySet<Map.Entry<K, V>>(entries(), EntrySet.ENTRY); >+ return new EntrySet<K, V>(entries()); > } > > /** >@@ -341,7 +341,7 @@ > * The set cannot be modified. > */ > public Set<K> keySet() { >- return new EntrySet<K>(entries(), EntrySet.KEY); >+ return new KeySet<K>(entries()); > } > > /** >@@ -352,7 +352,7 @@ > * The collection cannot be modified. > */ > public Collection<V> values() { >- return new EntrySet<V>(entries(), EntrySet.VALUE); >+ return new ValueSet<V>(entries()); > } > > /** >@@ -419,20 +419,57 @@ > * > * This class is immutable. > */ >- private static class EntrySet<E> extends AbstractSet<E> { >- private final Entry<?, ?>[] entries; >- private final int returnType; >- final static int ENTRY = 1; >- final static int KEY = 2; >- final static int VALUE = 3; >+ private static class EntrySet<K, V> extends AbstractSet<Map.Entry<K, V>> { >+ private final Entry<K, V>[] entries; > >- EntrySet(Entry<?, ?>[] entries, int returnType) { >+ EntrySet(Entry<K, V>[] entries) { > this.entries = entries; >- this.returnType = returnType; > } > >- public Iterator<E> iterator() { >- return new EntryIterator<E>(entries, returnType); >+ public Iterator<Map.Entry<K, V>> iterator() { >+ return new EntryIterator<K, V>(entries); >+ } >+ >+ public int size() { >+ return entries.length; >+ } >+ } >+ >+ /** >+ * Set class used for entry and key sets and values collections. >+ * >+ * This class is immutable. >+ */ >+ private static class KeySet<K> extends AbstractSet<K> { >+ private final Entry<K, ?>[] entries; >+ >+ KeySet(Entry<K, ?>[] entries) { >+ this.entries = entries; >+ } >+ >+ public Iterator<K> iterator() { >+ return new KeyIterator<K>(entries); >+ } >+ >+ public int size() { >+ return entries.length; >+ } >+ } >+ >+ /** >+ * Set class used for entry and key sets and values collections. >+ * >+ * This class is immutable. >+ */ >+ private static class ValueSet<V> extends AbstractSet<V> { >+ private final Entry<?, V>[] entries; >+ >+ ValueSet(Entry<?, V>[] entries) { >+ this.entries = entries; >+ } >+ >+ public Iterator<V> iterator() { >+ return new ValueIterator<V>(entries); > } > > public int size() { >@@ -444,39 +481,85 @@ > * Iterator class used for entry and key sets and values collections. > * > */ >- private static class EntryIterator<E> implements Iterator<E> { >- private final Entry<?, ?>[] entries; >- private final int returnType; >+ private static class EntryIterator<K, V> implements Iterator<Map.Entry<K, V>> { >+ private final Entry<K, V>[] entries; >+ private final int length; > private int cursor = 0; > >- EntryIterator(Entry<?, ?>[] entries, int returnType) { >+ EntryIterator(Entry<K, V>[] entries) { > this.entries = entries; >- this.returnType = returnType; >+ this.length = entries.length; > } > > public boolean hasNext() { >- return cursor < entries.length; >+ return cursor < length; > } > >- public E next() { >- if (cursor == entries.length) { >+ public Map.Entry<K, V> next() { >+ if (cursor == length) { > throw new NoSuchElementException(); > } >- switch (returnType) { >- case EntrySet.ENTRY : >- @SuppressWarnings("unchecked") >- E entry = (E) entries[cursor++]; >- return entry; >- case EntrySet.KEY : >- @SuppressWarnings("unchecked") >- E key = (E) entries[cursor++].key; >- return key; >- case EntrySet.VALUE : >- @SuppressWarnings("unchecked") >- E value = (E) entries[cursor++].value; >- return value; >+ return entries[cursor++]; >+ } >+ >+ public void remove() { >+ throw new UnsupportedOperationException(); // the collection cannot be modified. >+ } >+ } >+ >+ /** >+ * Iterator class used for entry and key sets and values collections. >+ * >+ */ >+ private static class KeyIterator<K> implements Iterator<K> { >+ private final Entry<K, ?>[] entries; >+ private final int length; >+ private int cursor = 0; >+ >+ KeyIterator(Entry<K, ?>[] entries) { >+ this.entries = entries; >+ this.length = entries.length; >+ } >+ >+ public boolean hasNext() { >+ return cursor < length; >+ } >+ >+ public K next() { >+ if (cursor == length) { >+ throw new NoSuchElementException(); >+ } >+ return entries[cursor++].key; >+ } >+ >+ public void remove() { >+ throw new UnsupportedOperationException(); // the collection cannot be modified. >+ } >+ } >+ >+ /** >+ * Iterator class used for entry and key sets and values collections. >+ * >+ */ >+ private static class ValueIterator<V> implements Iterator<V> { >+ private final Entry<?, V>[] entries; >+ private final int length; >+ private int cursor = 0; >+ >+ ValueIterator(Entry<?, V>[] entries) { >+ this.entries = entries; >+ this.length = entries.length; >+ } >+ >+ public boolean hasNext() { >+ return cursor < length; >+ } >+ >+ public V next() { >+ if (cursor == length) { >+ throw new NoSuchElementException(); > } >- throw new InternalError(); >+ return entries[cursor++].value; > } > > public void remove() {
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 326790
:
180064
|
180075
|
180093