diff options
author | David Robillard <d@drobilla.net> | 2020-02-09 14:41:18 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-02-09 14:41:18 +0100 |
commit | 3c29614ed1452868909840fc5307652ecc26d295 (patch) | |
tree | bf6cf3425f40538833e1d4dc47efe763b7ccf949 /src | |
parent | af5ec4bdda21e9a2f76f22050216a0b1cbbed575 (diff) | |
download | patchage-3c29614ed1452868909840fc5307652ecc26d295.tar.gz patchage-3c29614ed1452868909840fc5307652ecc26d295.tar.bz2 patchage-3c29614ed1452868909840fc5307652ecc26d295.zip |
Use range-based for loops in more places
Diffstat (limited to 'src')
-rw-r--r-- | src/Configuration.cpp | 16 | ||||
-rw-r--r-- | src/Patchage.cpp | 10 | ||||
-rw-r--r-- | src/PatchageCanvas.cpp | 6 | ||||
-rw-r--r-- | src/PatchageModule.cpp | 9 |
4 files changed, 18 insertions, 23 deletions
diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 0d6cfc0..0c86e3e 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -290,11 +290,10 @@ Configuration::save() // Try to find a writable configuration file const std::vector<std::string> filenames = get_filenames(); std::ofstream file; - for (size_t i = 0; i < filenames.size(); ++i) { - file.open(filenames[i].c_str(), std::ios::out); + for (const std::string& filename : filenames) { + file.open(filename.c_str(), std::ios::out); if (file.good()) { - std::cout << "Writing configuration to " << filenames[i] - << std::endl; + std::cout << "Writing configuration to " << filename << std::endl; break; } } @@ -325,12 +324,9 @@ Configuration::save() } file << std::dec << std::nouppercase; - for (std::map<std::string, ModuleSettings>::iterator i = - _module_settings.begin(); - i != _module_settings.end(); - ++i) { - const ModuleSettings& settings = (*i).second; - const std::string& name = (*i).first; + for (const auto& s : _module_settings) { + const std::string& name = s.first; + const ModuleSettings& settings = s.second; if (settings.split) { if (settings.input_location && settings.output_location) { diff --git a/src/Patchage.cpp b/src/Patchage.cpp index b400e85..b180f69 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -926,8 +926,8 @@ update_port_colors(GanvNode* node, void* data) return; } - for (PatchageModule::iterator i = pmod->begin(); i != pmod->end(); ++i) { - PatchagePort* port = dynamic_cast<PatchagePort*>(*i); + for (Ganv::Port* p : *pmod) { + PatchagePort* port = dynamic_cast<PatchagePort*>(p); if (port) { const uint32_t rgba = patchage->conf()->get_port_color(port->type()); @@ -1001,10 +1001,10 @@ Patchage::on_export_image() types["*.pdf"] = "Portable Document Format"; types["*.ps"] = "PostScript"; types["*.svg"] = "Scalable Vector Graphics"; - for (Types::const_iterator t = types.begin(); t != types.end(); ++t) { + for (const auto& t : types) { Gtk::FileFilter filt; - filt.add_pattern(t->first); - filt.set_name(t->second); + filt.add_pattern(t.first); + filt.set_name(t.second); dialog.add_filter(filt); } diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 828096b..1d64c1b 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -186,10 +186,8 @@ PatchageCanvas::remove_ports(bool (*pred)(const PatchagePort*)) i = next; } - for (std::set<PatchageModule*>::iterator i = data.empty.begin(); - i != data.empty.end(); - ++i) { - delete *i; + for (PatchageModule* m : data.empty) { + delete m; } } diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index db61392..cf2ba71 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -138,15 +138,16 @@ PatchageModule::join() void PatchageModule::menu_disconnect_all() { - for (iterator p = begin(); p != end(); ++p) - (*p)->disconnect(); + for (Ganv::Port* p : *this) { + p->disconnect(); + } } PatchagePort* PatchageModule::get_port(const std::string& name) { - for (iterator p = begin(); p != end(); ++p) { - PatchagePort* pport = dynamic_cast<PatchagePort*>(*p); + for (Ganv::Port* p : *this) { + PatchagePort* pport = dynamic_cast<PatchagePort*>(p); if (pport && pport->name() == name) { return pport; } |