Bug 103939 - On Motif: In a large virtual table Table.removeAll() is extremely slow.
Summary: On Motif: In a large virtual table Table.removeAll() is extremely slow.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: Other Unix All
: P3 normal (vote)
Target Milestone: 3.2 M1   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 113269 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-14 20:19 EDT by Mitch Rudominer CLA
Modified: 2005-10-20 15:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mitch Rudominer CLA 2005-07-14 20:19:23 EDT
All Motif:

Make a virtual table with three columns and 20,000 rows, each cell of the
table containing text of length about 20 characters.

Then call removeAll() on the table. The app will hang for almost a minute.

There is a workaround: Table.setItemCount(0) is not slow.

Examining the code, I believe that there is a severe inefficiency in the 
algorithm used in removeAll(). The main loop in removeAll() is:
        while (itemsCount > 0) {
		items [0].dispose (true);
	}
Examining the code in TableItem.dispose(boolean) we see that it delegates
to Table.destroyItem(TableItem item), and that this method works by creating
a new array of TableItems and copying the original array minus the item to be 
disposed. The net effect is that to delete a table with 20,000 rows what we are 
doing is first creating a table with 19,999 rows, then creating a table with 
19,998 rows etc. until finally we have an empty table. Clearly this is not an 
efficient algorithm.
Comment 1 Grant Gayed CLA 2005-07-21 17:00:37 EDT
fixed > 0721 in Table and Tree
Comment 2 Grant Gayed CLA 2005-10-20 15:26:50 EDT
*** Bug 113269 has been marked as a duplicate of this bug. ***