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

And adjust their types if necessary.
This commit is contained in:
Artur Wieczorek
2015-06-06 17:55:39 +02:00
parent 213df7dd88
commit 06013ea36f
6 changed files with 18 additions and 31 deletions

View File

@@ -1240,8 +1240,7 @@ bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const
wxColourData data; wxColourData data;
data.SetChooseFull(true); data.SetChooseFull(true);
data.SetColour(val.m_colour); data.SetColour(val.m_colour);
int i; for ( int i = 0; i < 16; i++ )
for ( i = 0; i < 16; i++)
{ {
wxColour colour(i*16, i*16, i*16); wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour); data.SetCustomColour(i, colour);
@@ -2028,15 +2027,15 @@ void wxMultiChoiceProperty::GenerateValueAsString( wxVariant& value,
strings = value.GetArrayString(); strings = value.GetArrayString();
wxString& tempStr = *target; wxString& tempStr = *target;
unsigned int i;
unsigned int itemCount = strings.size(); size_t itemCount = strings.size();
tempStr.Empty(); tempStr.Empty();
if ( itemCount ) if ( itemCount )
tempStr.append( wxS("\"") ); tempStr.append( wxS("\"") );
for ( i = 0; i < itemCount; i++ ) for ( size_t i = 0; i < itemCount; i++ )
{ {
tempStr.append( strings[i] ); tempStr.append( strings[i] );
tempStr.append( wxS("\"") ); tempStr.append( wxS("\"") );

View File

@@ -862,8 +862,7 @@ void wxPropertyGridManager::Clear()
m_pPropGrid->Freeze(); m_pPropGrid->Freeze();
int i; for ( int i=(int)GetPageCount()-1; i>=0; i-- )
for ( i=(int)GetPageCount()-1; i>=0; i-- )
RemovePage(i); RemovePage(i);
m_pPropGrid->Thaw(); m_pPropGrid->Thaw();

View File

@@ -889,7 +889,6 @@ void wxPGProperty::DoGenerateComposedValue( wxString& text,
const wxVariantList* valueOverrides, const wxVariantList* valueOverrides,
wxPGHashMapS2S* childResults ) const wxPGHashMapS2S* childResults ) const
{ {
int i;
int iMax = m_children.size(); int iMax = m_children.size();
text.clear(); text.clear();
@@ -921,6 +920,7 @@ void wxPGProperty::DoGenerateComposedValue( wxString& text,
} }
} }
int i;
for ( i = 0; i < iMax; i++ ) for ( i = 0; i < iMax; i++ )
{ {
wxVariant childValue; wxVariant childValue;
@@ -1523,8 +1523,7 @@ void wxPGProperty::SetFlagRecursively( wxPGPropertyFlags flag, bool set )
{ {
ChangeFlag(flag, set); ChangeFlag(flag, set);
unsigned int i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i = 0; i < GetChildCount(); i++ )
Item(i)->SetFlagRecursively(flag, set); Item(i)->SetFlagRecursively(flag, set);
} }
@@ -1603,8 +1602,7 @@ void wxPGProperty::DoEnable( bool enable )
SetFlag(wxPG_PROP_DISABLED); SetFlag(wxPG_PROP_DISABLED);
// Apply same to sub-properties as well // Apply same to sub-properties as well
unsigned int i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i = 0; i < GetChildCount(); i++ )
Item(i)->DoEnable( enable ); Item(i)->DoEnable( enable );
} }
@@ -2102,8 +2100,7 @@ bool wxPGProperty::DoHide( bool hide, int flags )
if ( flags & wxPG_RECURSE ) if ( flags & wxPG_RECURSE )
{ {
unsigned int i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i = 0; i < GetChildCount(); i++ )
Item(i)->DoHide(hide, flags | wxPG_RECURSE_STARTS); Item(i)->DoHide(hide, flags | wxPG_RECURSE_STARTS);
} }
@@ -2649,8 +2646,7 @@ void wxPGProperty::DeleteChildren()
bool wxPGProperty::IsChildSelected( bool recursive ) const bool wxPGProperty::IsChildSelected( bool recursive ) const
{ {
size_t i; for ( unsigned int i = 0; i < GetChildCount(); i++ )
for ( i = 0; i < GetChildCount(); i++ )
{ {
wxPGProperty* child = Item(i); wxPGProperty* child = Item(i);

View File

@@ -452,8 +452,7 @@ void wxPropertyGridInterface::DoSetPropertyAttribute( wxPGPropArg id, const wxSt
if ( argFlags & wxPG_RECURSE ) if ( argFlags & wxPG_RECURSE )
{ {
unsigned int i; for ( unsigned int i = 0; i < p->GetChildCount(); i++ )
for ( i = 0; i < p->GetChildCount(); i++ )
DoSetPropertyAttribute(p->Item(i), name, value, argFlags); DoSetPropertyAttribute(p->Item(i), name, value, argFlags);
} }
} }

View File

@@ -2073,8 +2073,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
// We need to find location of item. // We need to find location of item.
wxPGProperty* cat_parent = &m_regularArray; wxPGProperty* cat_parent = &m_regularArray;
int cat_index = m_regularArray.GetChildCount(); int cat_index = m_regularArray.GetChildCount();
size_t 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);
if ( p == item ) { cat_index = i; break; } if ( p == item ) { cat_index = i; break; }

View File

@@ -1636,9 +1636,8 @@ void wxFlagsProperty::OnSetValue()
long fullFlags = 0; long fullFlags = 0;
// normalize the value (i.e. remove extra flags) // normalize the value (i.e. remove extra flags)
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++ )
{ {
fullFlags |= choices.GetValue(i); fullFlags |= choices.GetValue(i);
} }
@@ -1684,10 +1683,9 @@ wxString wxFlagsProperty::ValueToString( wxVariant& value,
return text; return text;
long flags = value; long flags = value;
unsigned int i;
const wxPGChoices& choices = m_choices;
for ( i = 0; i < GetItemCount(); i++ ) const wxPGChoices& choices = m_choices;
for ( unsigned int i = 0; i < GetItemCount(); i++ )
{ {
int doAdd; int doAdd;
doAdd = ( (flags & choices.GetValue(i)) == choices.GetValue(i) ); doAdd = ( (flags & choices.GetValue(i)) == choices.GetValue(i) );
@@ -1747,8 +1745,7 @@ bool wxFlagsProperty::StringToValue( wxVariant& variant, const wxString& text, i
// Converts string id to a relevant bit. // Converts string id to a relevant bit.
long wxFlagsProperty::IdToBit( const wxString& id ) const long wxFlagsProperty::IdToBit( const wxString& id ) const
{ {
unsigned int i; for ( unsigned int i = 0; i < GetItemCount(); i++ )
for ( i = 0; i < GetItemCount(); i++ )
{ {
if ( id == GetLabel(i) ) if ( id == GetLabel(i) )
{ {
@@ -1765,8 +1762,7 @@ void wxFlagsProperty::RefreshChildren()
int flags = m_value.GetLong(); int flags = m_value.GetLong();
const wxPGChoices& choices = m_choices; const wxPGChoices& choices = m_choices;
unsigned int i; for ( unsigned int i = 0; i < GetItemCount(); i++ )
for ( i = 0; i < GetItemCount(); i++ )
{ {
long flag; long flag;
@@ -2740,7 +2736,6 @@ wxArrayStringProperty::ArrayStringToString( wxString& dst,
wxString pdr; wxString pdr;
wxString preas; wxString preas;
unsigned int i;
unsigned int itemCount = src.size(); unsigned int itemCount = src.size();
dst.Empty(); dst.Empty();
@@ -2757,7 +2752,7 @@ wxArrayStringProperty::ArrayStringToString( wxString& dst,
wxString delimStr(delimiter); wxString delimStr(delimiter);
for ( i = 0; i < itemCount; i++ ) for ( unsigned int i = 0; i < itemCount; i++ )
{ {
wxString str( src.Item(i) ); wxString str( src.Item(i) );