Reduce the scope of variables using to indexing single loop only.

And adjust their types if necessary (to have uniform types in the test expression).
This commit is contained in:
Artur Wieczorek
2015-05-28 19:39:14 +02:00
parent 6908275ed2
commit 0508087ce2
7 changed files with 34 additions and 68 deletions

View File

@@ -94,8 +94,7 @@ bool operator == (const wxArrayInt& array1, const wxArrayInt& array2)
{ {
if ( array1.size() != array2.size() ) if ( array1.size() != array2.size() )
return false; return false;
size_t i; for ( size_t i = 0; i < array1.size(); i++ )
for ( i=0; i<array1.size(); i++ )
{ {
if ( array1[i] != array2[i] ) if ( array1[i] != array2[i] )
return false; return false;
@@ -2134,8 +2133,7 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid,
value.push_back(extraStrings[n]); value.push_back(extraStrings[n]);
} }
unsigned int i; for ( size_t i = 0; i < arrInt.size(); i++ )
for ( i=0; i<arrInt.size(); i++ )
value.Add(m_choices.GetLabel(arrInt.Item(i))); value.Add(m_choices.GetLabel(arrInt.Item(i)));
if ( userStringMode == 2 ) if ( userStringMode == 2 )

View File

@@ -1032,8 +1032,7 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
} }
} }
unsigned int i; for ( unsigned int i = 0; i < cmnVals; i++ )
for ( i=0; i<cmnVals; i++ )
labels.Add(propGrid->GetCommonValueLabel(i)); labels.Add(propGrid->GetCommonValueLabel(i));
} }

View File

@@ -240,7 +240,7 @@ public:
virtual ~wxPGHeaderCtrl() virtual ~wxPGHeaderCtrl()
{ {
for (unsigned int i=0; i<m_columns.size(); i++ ) for (size_t i = 0; i < m_columns.size(); i++ )
delete m_columns[i]; delete m_columns[i];
} }
@@ -600,8 +600,7 @@ wxPropertyGridManager::~wxPropertyGridManager()
//m_pPropGrid->ClearSelection(); //m_pPropGrid->ClearSelection();
wxDELETE(m_pPropGrid); wxDELETE(m_pPropGrid);
size_t i; for ( size_t i = 0; i < m_arrPages.size(); i++ )
for ( i=0; i<m_arrPages.size(); i++ )
{ {
delete m_arrPages[i]; delete m_arrPages[i];
} }
@@ -644,8 +643,7 @@ bool wxPropertyGridManager::SetFont( const wxFont& font )
m_pPropGrid->SetFont(font); m_pPropGrid->SetFont(font);
// TODO: Need to do caption recacalculations for other pages as well. // TODO: Need to do caption recacalculations for other pages as well.
unsigned int i; for ( unsigned int i = 0; i < m_arrPages.size(); i++ )
for ( i=0; i<m_arrPages.size(); i++ )
{ {
wxPropertyGridPage* page = GetPage(i); wxPropertyGridPage* page = GetPage(i);
@@ -801,8 +799,7 @@ void wxPropertyGridManager::SelectPage( int index )
int wxPropertyGridManager::GetPageByName( const wxString& name ) const int wxPropertyGridManager::GetPageByName( const wxString& name ) const
{ {
size_t i; for ( size_t i = 0; i < GetPageCount(); i++ )
for ( i=0; i<GetPageCount(); i++ )
{ {
if ( m_arrPages[i]->m_label == name ) if ( m_arrPages[i]->m_label == name )
return i; return i;
@@ -816,8 +813,7 @@ int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState* pState
{ {
wxASSERT( pState ); wxASSERT( pState );
size_t i; for ( size_t i = 0; i < GetPageCount(); i++ )
for ( i=0; i<GetPageCount(); i++ )
{ {
if ( pState == m_arrPages[i]->GetStatePtr() ) if ( pState == m_arrPages[i]->GetStatePtr() )
return i; return i;
@@ -1060,8 +1056,7 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index,
bool wxPropertyGridManager::IsAnyModified() const bool wxPropertyGridManager::IsAnyModified() const
{ {
size_t i; for ( size_t i = 0; i < GetPageCount(); i++ )
for ( i=0; i<GetPageCount(); i++ )
{ {
if ( m_arrPages[i]->GetStatePtr()->m_anyModified ) if ( m_arrPages[i]->GetStatePtr()->m_anyModified )
return true; return true;
@@ -1687,8 +1682,7 @@ void wxPropertyGridManager::RecreateControls()
wxPGProperty* wxPropertyGridManager::DoGetPropertyByName( const wxString& name ) const wxPGProperty* wxPropertyGridManager::DoGetPropertyByName( const wxString& name ) const
{ {
size_t i; for ( size_t i = 0; i < GetPageCount(); i++ )
for ( i=0; i<GetPageCount(); i++ )
{ {
wxPropertyGridPageState* pState = m_arrPages[i]->GetStatePtr(); wxPropertyGridPageState* pState = m_arrPages[i]->GetStatePtr();
wxPGProperty* p = pState->BaseGetPropertyByName(name); wxPGProperty* p = pState->BaseGetPropertyByName(name);
@@ -1862,9 +1856,8 @@ void wxPropertyGridManager::SetSplitterLeft( bool subProps, bool allPages )
dc.SetFont(m_pPropGrid->GetFont()); dc.SetFont(m_pPropGrid->GetFont());
int highest = 0; int highest = 0;
unsigned int i;
for ( i=0; i<GetPageCount(); i++ ) for ( size_t i = 0; i < GetPageCount(); i++ )
{ {
int maxW = m_pState->GetColumnFitWidth(dc, m_arrPages[i]->DoGetRoot(), 0, subProps ); int maxW = m_pState->GetColumnFitWidth(dc, m_arrPages[i]->DoGetRoot(), 0, subProps );
maxW += m_pPropGrid->GetMarginWidth(); maxW += m_pPropGrid->GetMarginWidth();
@@ -2118,8 +2111,7 @@ void wxPropertyGridManager::SetSplitterPosition( int pos, int splitterColumn )
wxASSERT_MSG( GetPageCount(), wxASSERT_MSG( GetPageCount(),
wxT("SetSplitterPosition() has no effect until pages have been added") ); wxT("SetSplitterPosition() has no effect until pages have been added") );
size_t i; for ( size_t i = 0; i < GetPageCount(); i++ )
for ( i=0; i<GetPageCount(); i++ )
{ {
wxPropertyGridPage* page = GetPage(i); wxPropertyGridPage* page = GetPage(i);
page->DoSetSplitterPosition( pos, splitterColumn, page->DoSetSplitterPosition( pos, splitterColumn,

View File

@@ -1482,8 +1482,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
// value is <composed> // value is <composed>
if ( AreChildrenComponents() ) if ( AreChildrenComponents() )
{ {
unsigned int i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i=0; i<GetChildCount(); i++ )
Item(i)->SetValue(value, NULL, flags|wxPG_SETVAL_FROM_PARENT); Item(i)->SetValue(value, NULL, flags|wxPG_SETVAL_FROM_PARENT);
} }
} }
@@ -1894,8 +1893,7 @@ wxString wxPGProperty::GetFlagsAsString( FlagType flagsMask ) const
int relevantFlags = m_flags & flagsMask & wxPG_STRING_STORED_FLAGS; int relevantFlags = m_flags & flagsMask & wxPG_STRING_STORED_FLAGS;
FlagType a = 1; FlagType a = 1;
unsigned int i = 0; for ( unsigned int i = 0; i < gs_propFlagToStringSize; i++ )
for ( i=0; i<gs_propFlagToStringSize; i++ )
{ {
if ( relevantFlags & a ) if ( relevantFlags & a )
{ {
@@ -1916,8 +1914,7 @@ void wxPGProperty::SetFlagsFromString( const wxString& str )
FlagType flags = 0; FlagType flags = 0;
WX_PG_TOKENIZER1_BEGIN(str, wxS('|')) WX_PG_TOKENIZER1_BEGIN(str, wxS('|'))
unsigned int i; for ( unsigned int i = 0; i < gs_propFlagToStringSize; i++ )
for ( i=0; i<gs_propFlagToStringSize; i++ )
{ {
const wxChar* fs = gs_propFlagToString[i]; const wxChar* fs = gs_propFlagToString[i];
if ( fs && str == fs ) if ( fs && str == fs )
@@ -2114,9 +2111,7 @@ bool wxPGProperty::DoHide( bool hide, int flags )
bool wxPGProperty::HasVisibleChildren() const bool wxPGProperty::HasVisibleChildren() const
{ {
unsigned int i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i=0; i<GetChildCount(); i++ )
{ {
wxPGProperty* child = Item(i); wxPGProperty* child = Item(i);
@@ -2411,13 +2406,12 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
else else
allChildrenSpecified = true; allChildrenSpecified = true;
unsigned int i;
unsigned int n = 0; unsigned int n = 0;
wxVariant childValue = list[n]; wxVariant childValue = list[n];
//wxLogDebug(wxT(">> %s.AdaptListToValue()"),GetBaseName().c_str()); //wxLogDebug(wxT(">> %s.AdaptListToValue()"),GetBaseName().c_str());
for ( i=0; i<GetChildCount(); i++ ) for ( unsigned int i = 0; i < GetChildCount(); i++ )
{ {
const wxPGProperty* child = Item(i); const wxPGProperty* child = Item(i);
@@ -2448,8 +2442,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
void wxPGProperty::FixIndicesOfChildren( unsigned int starthere ) void wxPGProperty::FixIndicesOfChildren( unsigned int starthere )
{ {
size_t i; for ( unsigned int i = starthere; i < GetChildCount(); i++)
for ( i=starthere;i<GetChildCount();i++)
Item(i)->m_arrIndex = i; Item(i)->m_arrIndex = i;
} }
@@ -2457,9 +2450,7 @@ void wxPGProperty::FixIndicesOfChildren( unsigned int starthere )
// Returns (direct) child property with given name (or NULL if not found) // Returns (direct) child property with given name (or NULL if not found)
wxPGProperty* wxPGProperty::GetPropertyByName( const wxString& name ) const wxPGProperty* wxPGProperty::GetPropertyByName( const wxString& name ) const
{ {
size_t i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i=0; i<GetChildCount(); i++ )
{ {
wxPGProperty* p = Item(i); wxPGProperty* p = Item(i);
if ( p->m_name == name ) if ( p->m_name == name )
@@ -2613,10 +2604,9 @@ wxPGProperty* wxPGProperty::GetItemAtY( unsigned int y,
void wxPGProperty::Empty() void wxPGProperty::Empty()
{ {
size_t i;
if ( !HasFlag(wxPG_PROP_CHILDREN_ARE_COPIES) ) if ( !HasFlag(wxPG_PROP_CHILDREN_ARE_COPIES) )
{ {
for ( i=0; i<GetChildCount(); i++ ) for ( size_t i = 0; i < GetChildCount(); i++ )
{ {
delete m_children[i]; delete m_children[i];
} }
@@ -2684,8 +2674,6 @@ wxVariant wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const
{ {
unsigned int i;
const wxVariantList* pList = NULL; const wxVariantList* pList = NULL;
wxVariantList::const_iterator node; wxVariantList::const_iterator node;
@@ -2695,7 +2683,7 @@ bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const
node = pList->begin(); node = pList->begin();
} }
for ( i=0; i<GetChildCount(); i++ ) for ( unsigned int i = 0; i < GetChildCount(); i++ )
{ {
wxPGProperty* child = Item(i); wxPGProperty* child = Item(i);
const wxVariant* listValue = NULL; const wxVariant* listValue = NULL;
@@ -3023,8 +3011,7 @@ int wxPGChoices::Index( const wxString& str ) const
{ {
if ( IsOk() ) if ( IsOk() )
{ {
unsigned int i; for ( unsigned int i = 0; i < m_data->GetCount(); i++ )
for ( i=0; i< m_data->GetCount(); i++ )
{ {
const wxPGChoiceEntry& entry = m_data->Item(i); const wxPGChoiceEntry& entry = m_data->Item(i);
if ( entry.HasText() && entry.GetText() == str ) if ( entry.HasText() && entry.GetText() == str )
@@ -3040,8 +3027,7 @@ int wxPGChoices::Index( int val ) const
{ {
if ( IsOk() ) if ( IsOk() )
{ {
unsigned int i; for ( unsigned int i = 0; i < m_data->GetCount(); i++ )
for ( i=0; i< m_data->GetCount(); i++ )
{ {
const wxPGChoiceEntry& entry = m_data->Item(i); const wxPGChoiceEntry& entry = m_data->Item(i);
if ( entry.GetValue() == val ) if ( entry.GetValue() == val )
@@ -3056,10 +3042,9 @@ int wxPGChoices::Index( int val ) const
wxArrayString wxPGChoices::GetLabels() const wxArrayString wxPGChoices::GetLabels() const
{ {
wxArrayString arr; wxArrayString arr;
unsigned int i;
if ( this && IsOk() ) if ( this && IsOk() )
for ( i=0; i<GetCount(); i++ ) for ( unsigned int i = 0; i < GetCount(); i++ )
arr.push_back(GetLabel(i)); arr.push_back(GetLabel(i));
return arr; return arr;
@@ -3073,8 +3058,7 @@ wxArrayInt wxPGChoices::GetValuesForStrings( const wxArrayString& strings ) cons
if ( IsOk() ) if ( IsOk() )
{ {
unsigned int i; for ( size_t i = 0; i < strings.size(); i++ )
for ( i=0; i< strings.size(); i++ )
{ {
int index = Index(strings[i]); int index = Index(strings[i]);
if ( index >= 0 ) if ( index >= 0 )
@@ -3096,8 +3080,7 @@ wxArrayInt wxPGChoices::GetIndicesForStrings( const wxArrayString& strings,
if ( IsOk() ) if ( IsOk() )
{ {
unsigned int i; for ( size_t i = 0; i < strings.size(); i++ )
for ( i=0; i< strings.size(); i++ )
{ {
const wxString& str = strings[i]; const wxString& str = strings[i];
int index = Index(str); int index = Index(str);

View File

@@ -2267,10 +2267,9 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc,
} }
// Splitters // Splitters
unsigned int si;
int sx = x; int sx = x;
for ( si = 0; si < colCount; si++ ) for ( unsigned int si = 0; si < colCount; si++ )
{ {
sx += colWidths[si]; sx += colWidths[si];
dc.DrawLine( sx, y, sx, y2 ); dc.DrawLine( sx, y, sx, y2 );

View File

@@ -339,9 +339,7 @@ void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
VirtualHeightChanged(); VirtualHeightChanged();
// Recalculate caption text extents. // Recalculate caption text extents.
unsigned int i; for ( unsigned int i = 0; i < m_regularArray.GetChildCount();i++ )
for ( i=0;i<m_regularArray.GetChildCount();i++ )
{ {
wxPGProperty* p =m_regularArray.Item(i); wxPGProperty* p =m_regularArray.Item(i);
@@ -788,11 +786,10 @@ int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC& dc,
bool subProps) const bool subProps) const
{ {
wxPropertyGrid* pg = m_pPropGrid; wxPropertyGrid* pg = m_pPropGrid;
size_t i;
int maxW = 0; int maxW = 0;
int w, h; int w, h;
for ( i=0; i<pwc->GetChildCount(); i++ ) for ( unsigned int i = 0; i <pwc->GetChildCount(); i++ )
{ {
wxPGProperty* p = pwc->Item(i); wxPGProperty* p = pwc->Item(i);
if ( !p->IsCategory() ) if ( !p->IsCategory() )
@@ -850,8 +847,7 @@ int wxPropertyGridPageState::GetColumnFullWidth( wxClientDC &dc, wxPGProperty *p
int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn ) const int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn ) const
{ {
int n = GetGrid()->GetMarginWidth(); int n = GetGrid()->GetMarginWidth();
int i; for ( int i = 0; i <= splitterColumn; i++ )
for ( i=0; i<=splitterColumn; i++ )
n += m_colWidths[i]; n += m_colWidths[i];
return n; return n;
} }
@@ -1479,8 +1475,7 @@ wxVariant wxPropertyGridPageState::DoGetPropertyValues( const wxString& listname
{ {
wxASSERT( !pwc->HasFlag(wxPG_PROP_AGGREGATE) ); wxASSERT( !pwc->HasFlag(wxPG_PROP_AGGREGATE) );
size_t i; for ( unsigned int i = 0; i < pwc->GetChildCount(); i++ )
for ( i=0; i<pwc->GetChildCount(); i++ )
{ {
wxPGProperty* p = pwc->Item(i); wxPGProperty* p = pwc->Item(i);
if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) ) if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) )

View File

@@ -1486,7 +1486,6 @@ void wxFlagsProperty::Init()
// //
// Generate children // Generate children
// //
unsigned int i;
unsigned int prevChildCount = m_children.size(); unsigned int prevChildCount = m_children.size();
@@ -1512,6 +1511,8 @@ void wxFlagsProperty::Init()
state->DoClearSelection(); state->DoClearSelection();
} }
unsigned int i;
// Delete old children // Delete old children
for ( i=0; i<prevChildCount; i++ ) for ( i=0; i<prevChildCount; i++ )
delete m_children[i]; delete m_children[i];
@@ -1664,9 +1665,8 @@ void wxFlagsProperty::OnSetValue()
if ( newFlags != m_oldValue ) if ( newFlags != m_oldValue )
{ {
// Set child modified states // Set child modified states
unsigned int i;
const wxPGChoices& choices = m_choices; const wxPGChoices& choices = m_choices;
for ( i = 0; i<GetItemCount(); i++ ) for ( unsigned int i = 0; i < GetItemCount(); i++ )
{ {
int flag; int flag;