From: Vadim Zeitlin Date: Thu, 22 Dec 2011 14:47:54 +0000 (+0000) Subject: Dramatically optimise inserting many items in wxGenericListCtrl. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b25278d885906c601a53fe4ddb246da2f68f66f9 Dramatically optimise inserting many items in wxGenericListCtrl. During each item insertion SetItem() was called and this resulted in a call to GetItemRect() which, in turn, re-laid out all items in the control meaning that the relatively expensive wxListMainWindow::RecalculatePositions() was called N times when inserting N items. Reduce this to just a single call by not refreshing the item in SetItem() if everything is going to be redrawn soon anyhow. This decreases the time needed to insert a couple of thousands of items in icon view from several minutes to less than a second. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 6f02e43f3a..481654ecd8 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -3181,10 +3181,14 @@ void wxListMainWindow::SetItem( wxListItem &item ) } } - // update the item on screen - wxRect rectItem; - GetItemRect(id, rectItem); - RefreshRect(rectItem); + // update the item on screen unless we're going to update everything soon + // anyhow + if ( !m_dirty ) + { + wxRect rectItem; + GetItemRect(id, rectItem); + RefreshRect(rectItem); + } } void wxListMainWindow::SetItemStateAll(long state, long stateMask)