]> git.saurik.com Git - wxWidgets.git/commitdiff
Optimization: skip 0-sized cells in wxGrid::CalcCellsExposed().
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Aug 2012 15:36:25 +0000 (15:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 3 Aug 2012 15:36:25 +0000 (15:36 +0000)
There is no need to compute intersections with 0-sized cells, skip them to
speed up refresh of big grids.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72292 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/grid.cpp

index 337c2264e0339c3d93a18b28066b5289b88819be..a4e705841f6affb5e5d5366c3222aa53d439abc1 100644 (file)
@@ -3167,16 +3167,20 @@ wxArrayInt wxGrid::CalcColLabelsExposed( const wxRegion& reg ) const
 
 wxGridCellCoordsArray wxGrid::CalcCellsExposed( const wxRegion& reg ) const
 {
-    wxRegionIterator iter( reg );
     wxRect r;
 
     wxGridCellCoordsArray  cellsExposed;
 
     int left, top, right, bottom;
-    while ( iter )
+    for ( wxRegionIterator iter(reg); iter; ++iter )
     {
         r = iter.GetRect();
 
+        // Skip 0-height cells, they're invisible anyhow, don't waste time
+        // getting their rectangles and so on.
+        if ( !r.GetHeight() )
+            continue;
+
         // TODO: remove this when we can...
         // There is a bug in wxMotif that gives garbage update
         // rectangles if you jump-scroll a long way by clicking the
@@ -3224,8 +3228,6 @@ wxGridCellCoordsArray wxGrid::CalcCellsExposed( const wxRegion& reg ) const
             for ( size_t n = 0; n < count; n++ )
                 cellsExposed.Add(wxGridCellCoords(row, cols[n]));
         }
-
-        ++iter;
     }
 
     return cellsExposed;