]> git.saurik.com Git - wxWidgets.git/commitdiff
Dramatically optimise inserting many items in wxGenericListCtrl.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Dec 2011 14:47:54 +0000 (14:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 22 Dec 2011 14:47:54 +0000 (14:47 +0000)
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

src/generic/listctrl.cpp

index 6f02e43f3a317a9e828e1b265346a8a81864fdb7..481654ecd854bf43afab5d1edeaa2dd9f01a063c 100644 (file)
@@ -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)