From b3ad8dae849ae6f9c3d40b09352a84e9c7a1bf0d Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 24 May 2015 20:36:16 +0200 Subject: [PATCH] Use empty() member function to determine if arrays are empty in wxPG. Use this dedicated function instead of checking if size() function returns zero/non-zero value. --- include/wx/propgrid/propgridpagestate.h | 4 +--- src/propgrid/propgrid.cpp | 11 ++++------- src/propgrid/propgridiface.cpp | 2 +- src/propgrid/propgridpagestate.cpp | 6 +----- src/propgrid/props.cpp | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index e1a64cc221..14977e7737 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -526,9 +526,7 @@ public: */ wxPGProperty* GetSelection() const { - if ( m_selection.size() == 0 ) - return NULL; - return m_selection[0]; + return m_selection.empty()? NULL: m_selection[0]; } void DoSetSelection( wxPGProperty* prop ) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 19c6ba4fc3..a7d0a5414b 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -722,7 +722,7 @@ bool wxPropertyGrid::DoAddToSelection( wxPGProperty* prop, int selFlags ) wxArrayPGProperty& selection = m_pState->m_selection; - if ( !selection.size() ) + if ( selection.empty() ) { return DoSelectProperty(prop, selFlags); } @@ -935,7 +935,7 @@ bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty* prop, void wxPropertyGrid::DoSetSelection( const wxArrayPGProperty& newSelection, int selFlags ) { - if ( newSelection.size() > 0 ) + if ( !newSelection.empty() ) { if ( !DoSelectProperty(newSelection[0], selFlags) ) return; @@ -4065,10 +4065,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) wxArrayPGProperty prevSelection = m_pState->m_selection; wxPGProperty* prevFirstSel; - if ( prevSelection.size() > 0 ) - prevFirstSel = prevSelection[0]; - else - prevFirstSel = NULL; + prevFirstSel = prevSelection.empty()? NULL: prevSelection[0]; if ( prevFirstSel && prevFirstSel->HasFlag(wxPG_PROP_BEING_DELETED) ) prevFirstSel = NULL; @@ -6251,7 +6248,7 @@ void wxPGChoicesData::Clear() void wxPGChoicesData::CopyDataFrom( wxPGChoicesData* data ) { - wxASSERT( m_items.size() == 0 ); + wxASSERT( m_items.empty() ); m_items = data->m_items; } diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index 9f368b629d..6fdd07fe0d 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -1036,7 +1036,7 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res { if ( restoreStates & SelectionState ) { - if ( values.size() > 0 ) + if ( !values.empty() ) { if ( pageState->IsDisplayed() ) { diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 840b988e9d..4e5f01400f 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -1381,11 +1381,7 @@ void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty* prop ) wxArrayPGProperty sel = m_selection; sel.erase( sel.begin() + i ); - wxPGProperty* newFirst; - if ( sel.size() ) - newFirst = sel[0]; - else - newFirst = NULL; + wxPGProperty* newFirst = sel.empty()? NULL: sel[0]; pg->DoSelectProperty(newFirst, wxPG_SEL_DONT_SEND_EVENT); diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 166bce90c1..47abaf398b 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -1207,7 +1207,7 @@ wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, { SetIndex(0); - if ( &labels && labels.size() ) + if ( &labels && !labels.empty() ) { m_choices.Set(labels, values); @@ -1595,7 +1595,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, { m_oldChoicesData = NULL; - if ( &labels && labels.size() ) + if ( &labels && !labels.empty() ) { m_choices.Set(labels,values);