]> git.tdb.fi Git - builder.git/blobdiff - source/binarycomponent.cpp
Replace basic for loops with range-based loops or algorithms
[builder.git] / source / binarycomponent.cpp
index 49c4897ce69d7d25492ebe1521257dca04c77062..2cd6f853ca42db8472e7c4193c1e5f633d5f605f 100644 (file)
@@ -17,22 +17,21 @@ void BinaryComponent::create_build_info()
 {
        Component::create_build_info();
 
-       for(UseList::const_iterator i=uses.begin(); i!=uses.end(); ++i)
+       for(const Component *u: uses)
        {
                /* Select an include path that contains all the sources for this and the
                used component.  This should produce a sensible result in most cases. */
                FS::Path base;
-               for(SourceList::const_iterator j=sources.begin(); j!=sources.end(); ++j)
-                       base = base.empty() ? *j : FS::common_ancestor(base, *j);
-               const SourceList &use_sources = (*i)->get_sources();
-               for(SourceList::const_iterator j=use_sources.begin(); j!=use_sources.end(); ++j)
-                       base = FS::common_ancestor(base, *j);
+               for(const FS::Path &s: sources)
+                       base = base.empty() ? s : FS::common_ancestor(base, s);
+               for(const FS::Path &s: u->get_sources())
+                       base = FS::common_ancestor(base, s);
                build_info.incpath.push_back(base);
-               build_info.libs.push_back((*i)->get_name());
-               if(!(*i)->get_install())
+               build_info.libs.push_back(u->get_name());
+               if(!u->get_install())
                {
-                       build_info.libmodes[(*i)->get_name()] = BuildInfo::STATIC;
-                       build_info.libpath.push_back((*i)->get_package().get_output_directory());
+                       build_info.libmodes[u->get_name()] = BuildInfo::STATIC;
+                       build_info.libpath.push_back(u->get_package().get_output_directory());
                }
        }
 
@@ -56,7 +55,7 @@ void BinaryComponent::create_targets() const
 
        list<Target *> objs;
        SourceList source_filenames = collect_source_files();
-       for(SourceList::iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
+       for(auto i=source_filenames.begin(); i!=source_filenames.end(); ++i)
        {
                string ext = FS::extpart(FS::basename(*i));
                Target *src = 0;
@@ -109,10 +108,9 @@ void BinaryComponent::create_targets() const
                                if(dynamic_cast<FileTarget *>(src)->is_installable())
                                        build_graph.add_installed_target(*src);
 
-                               const Target::Dependencies &side_effects = src->get_side_effects();
-                               for(Target::Dependencies::const_iterator j=side_effects.begin(); j!=side_effects.end(); ++j)
-                                       if(dynamic_cast<FileTarget *>(*j)->is_installable())
-                                               build_graph.add_installed_target(**j);
+                               for(Target *s: src->get_side_effects())
+                                       if(dynamic_cast<FileTarget *>(s)->is_installable())
+                                               build_graph.add_installed_target(*s);
                        }
                }
        }
@@ -131,11 +129,11 @@ void BinaryComponent::create_targets() const
        else
                results.push_back(linker.create_target(objs));
 
-       for(list<Target *>::const_iterator i=results.begin(); i!=results.end(); ++i)
+       for(Target *r: results)
        {
-               build_graph.add_primary_target(**i);
+               build_graph.add_primary_target(*r);
                if(install)
-                       build_graph.add_installed_target(**i);
+                       build_graph.add_installed_target(*r);
        }
 }