From 9e57072a901279366866a19b9703589eac8383d7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Aug 2012 15:36:25 +0000 Subject: [PATCH] Optimization: skip 0-sized cells in wxGrid::CalcCellsExposed(). 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 337c2264e0..a4e705841f 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -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; -- 2.47.2