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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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