Bug 27108 - [JFace] ListenerList should default its size to 1
Summary: [JFace] ListenerList should default its size to 1
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-11-25 12:32 EST by Adam Kiezun CLA
Modified: 2002-12-09 09:06 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2002-11-25 12:32:57 EST
i'm having a hard time finding a single instance of ListenerList class 
(i'm running under a profiler) 
in which the list would contain more than 1 element

so the other 2 are almost always wasted
because this class is instantiated many, many times (i just started and see 
more than 1300 instances) the default size should be 1. 
It can then grow if necessary.

(This class should really live in core - because it does not, everybody copied 
it. So more reports will be needed)
Comment 1 Adam Kiezun CLA 2002-11-25 12:34:35 EST
see bug  27110 - for the JDT ui copy of that class
Comment 2 Nick Edgar CLA 2002-12-04 16:30:28 EST
Added trace statements to add, remove and clear, showing the size.
Had a resource perspective open, opened a Java perspective, and opened several 
preference pages.
The majority of the listener lists had 1 listener.  
Of about 1000 listeners, the histogram of sizes (size -> number of listeners 
with that max size) is:
0: 8
1: ~950 (the rest)
2: 25
3: 4
4: 1
5: 5

Also saw counts of 12, 18, 26, 27, 28, 46, 56, 39, 87, and 102.

Changing the default capacity to 1.  It still grows the same way (2*N+1 each 
time), so this only adds one growth step for the other cases.

Comment 3 Nick Edgar CLA 2002-12-04 16:31:05 EST
Released.
Comment 4 Adam Kiezun CLA 2002-12-09 09:06:49 EST
entered bug 27938 for the wrong home of this class