开发者

Remove items from SWT tables

开发者 https://www.devze.com 2022-12-27 09:11 出处:网络
This is more of an answer I\'d like to share for the problem I was chasing for some time in RCP application using large SWT tables.

This is more of an answer I'd like to share for the problem I was chasing for some time in RCP application using large SWT tables.

The problem is the performance of SWT Table.remove(int start, int end) method. It gives really bad performance - about 50msec per 100 items on my Windows XP. But the real show stopper was on Vista and Windows 7, where deleting 100 items would take up to 5 second开发者_运维百科s! Looking into the source code of the Table shows that there are huge amount of windowing events flying around in this call.. That brings the windowing system to its knees.

The solution was to hide the damn thing during this call:

table.setVisible(false);
table.remove(from, to);
table.setVisible(true);

That does wonders - deleting 500 items on both XP & Windows7 takes ~15msec, which is just an overhead for printing out time stamps I used.

nice :)


Instead of table.setVisible(), you should rather use table.setRedraw(). This method on Control has exactly the purpose of suppressing drawing operations during expensive updates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号