Community
Participate
Working Groups
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); }
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!
This is fixed in the 3.2 stream. *** This bug has been marked as a duplicate of 103939 ***
Also, note the workaround in the other report: Table.setItemCount(0) is not slow.
Thanks Grant, setItemCount(0) looks like it works well! I swear I did try to find another bug report, but obviously missed 103939.