switch simple loops that don't need indices to being iterator-based

This commit is contained in:
Vern Paxson 2021-08-19 09:38:50 -07:00
parent ffd1905f90
commit d609a11312
8 changed files with 34 additions and 52 deletions

View file

@ -145,9 +145,8 @@ void CPPCompile::ExpandListTypeVar(const TypePtr& t, string& tn)
const auto& tl = t->AsTypeList()->GetTypes();
auto t_name = tn + "->AsTypeList()";
for ( auto i = 0u; i < tl.size(); ++i )
AddInit(t, t_name + "->Append(" +
GenTypeName(tl[i]) + ");");
for ( auto& tl_i : tl )
AddInit(t, t_name + "->Append(" + GenTypeName(tl_i) + ");");
}
void CPPCompile::ExpandRecordTypeVar(const TypePtr& t, string& tn)
@ -459,10 +458,10 @@ void CPPCompile::RegisterListType(const TypePtr& t)
{
const auto& tl = t->AsTypeList()->GetTypes();
for ( auto i = 0u; i < tl.size(); ++i )
for ( auto& tl_i : tl )
{
NoteNonRecordInitDependency(t, tl[i]);
RegisterType(tl[i]);
NoteNonRecordInitDependency(t, tl_i);
RegisterType(tl_i);
}
}
@ -489,10 +488,8 @@ void CPPCompile::RegisterRecordType(const TypePtr& t)
if ( ! r )
return;
for ( auto i = 0; i < r->length(); ++i )
for ( const auto& r_i : *r )
{
const auto& r_i = (*r)[i];
NoteNonRecordInitDependency(t, r_i->type);
RegisterType(r_i->type);