Bug 113269 - Performance of virtual Table removeAll on Solaris Motif very poor
Summary: Performance of virtual Table removeAll on Solaris Motif very poor
Status: RESOLVED DUPLICATE of bug 103939
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: Sun Solaris-Motif
: P3 major with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-20 14:53 EDT by Brian Nettleton CLA
Modified: 2005-10-21 01:29 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Nettleton CLA 2005-10-20 14:53:07 EDT
The performance of Table.removeAll() under Solaris Motif is very poor.  The 
current algorithm has an exponential time complexity and a simple change 
converts this to a linear time complexity.  Function Table.removeAll removes 
all items in the list starting with the first item.  Removing an item involves 
shifting all the following items left one position and updating each following 
item's index.  A simple change is to instead remove the items in the list 
starting with the last and moving towards the first element.

This change is easily implemented by changing the while loop in Table.removeAll 
from:

	while (itemsCount > 0) {
		items [0].dispose (true);
	}


to:

	while (itemsCount > 0) {
		items [itemsCount - 1].dispose (true);
	}
Comment 1 Billy Biggs CLA 2005-10-20 15:14:31 EDT
It does change the order of the dispose callbacks though.  Still, avoiding the
array shifting isn't hard even if you keep the event order.  Seems like a good
change!
Comment 2 Grant Gayed CLA 2005-10-20 15:26:50 EDT
This is fixed in the 3.2 stream.


*** This bug has been marked as a duplicate of 103939 ***
Comment 3 Grant Gayed CLA 2005-10-20 15:30:09 EDT
Also, note the workaround in the other report: Table.setItemCount(0) is not 
slow.
Comment 4 Brian Nettleton CLA 2005-10-21 01:29:46 EDT
Thanks Grant, setItemCount(0) looks like it works well!  I swear I did try to 
find another bug report, but obviously missed 103939.