Bug 23562 - [JFace] ListenerList#remove(Object) does extra work
Summary: [JFace] ListenerList#remove(Object) does extra work
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: Other All
: P3 normal (vote)
Target Milestone: 2.1 RC1   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2002-09-13 10:08 EDT by Jared Burns CLA
Modified: 2003-02-19 15:07 EST (History)
0 users

See Also:


Attachments
listenerlistpatch.txt - a proposed patch (578 bytes, patch)
2002-09-13 10:11 EDT, Jared Burns CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2002-09-13 10:08:25 EDT
The method org.eclipse.jface.util.ListenerList#remove(Object) does a lot of 
work to maintain the ordering of the items in the list. The ListenerList API 
doesn't say that the list is an ordered list, however, so this work isn't 
necessary.

Instead of removing the element and shifting all elements to close the gap, 
the list should just replace the removed element with the last element in the 
array, null the last element in the array, and decrement the item count.
Comment 1 Jared Burns CLA 2002-09-13 10:11:43 EDT
Created attachment 1989 [details]
listenerlistpatch.txt - a proposed patch
Comment 2 Nick Edgar CLA 2003-02-10 10:05:00 EST
Although it's not spec'ed, the fact that the listener list preserves order is 
important.  If there are real cases where the performance of the current 
implementation is unacceptable, then we can reconsider the implementation, e.g. 
use a linked list.

The spec should be clarified re order.
Comment 3 Nick Edgar CLA 2003-02-19 15:07:19 EST
Changed getListeners() to state:
	 * Returns an array containing all the registered listeners,
	 * in the order in which they were added.