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

View File

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

View File

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

View File

@@ -452,8 +452,7 @@ void wxPropertyGridInterface::DoSetPropertyAttribute( wxPGPropArg id, const wxSt
if ( argFlags & wxPG_RECURSE )
{
unsigned int i;
for ( i = 0; i < p->GetChildCount(); i++ )
for ( unsigned int i = 0; i < p->GetChildCount(); i++ )
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.
wxPGProperty* cat_parent = &m_regularArray;
int cat_index = m_regularArray.GetChildCount();
size_t 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);
if ( p == item ) { cat_index = i; break; }

View File

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