From f6410588cfcce180657a6c9da0cbe64870eef868 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 22 Aug 2011 14:14:53 +0000 Subject: [PATCH] Don't iterate over selection twice needlessly in wxDataViewMainWindow::ItemDeleted(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 9511f209d4..7cebed518a 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2023,16 +2023,19 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, { const int row = GetRowByItem(item); + int rowIndexInSelection = wxNOT_FOUND; + const size_t selCount = m_selection.size(); for ( size_t i = 0; i < selCount; i++ ) { - if ( m_selection[i] > (unsigned)row ) + if ( m_selection[i] == (unsigned)row ) + rowIndexInSelection = i; + else if ( m_selection[i] > (unsigned)row ) m_selection[i]--; } - int itemRow = m_selection.Index(row); - if ( itemRow != wxNOT_FOUND ) - m_selection.RemoveAt(itemRow); + if ( rowIndexInSelection != wxNOT_FOUND ) + m_selection.RemoveAt(rowIndexInSelection); } } -- 2.50.0