diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index 1fd0039a..8811e0a1 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -286,9 +286,8 @@ DownloadFactory::receive_success() { if (torrent::log_groups[torrent::LOG_TORRENT_DEBUG].valid()) log_created(download, rtorrent); - std::for_each(m_commands.begin(), m_commands.end(), [&download](const std::string& cmd) { - rpc::parse_command_multiple_std(cmd, rpc::make_target(download)); - }); + for (const auto& command : m_commands) + rpc::parse_command_multiple_std(command, rpc::make_target(download)); if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end()) throw torrent::input_error("The newly created download was removed."); diff --git a/src/core/download_list.cc b/src/core/download_list.cc index 3c23f625..5c024e6a 100644 --- a/src/core/download_list.cc +++ b/src/core/download_list.cc @@ -167,8 +167,10 @@ DownloadList::insert(Download* download) { // This needs to be separated into two different calls to ensure // the download remains in the view. - std::for_each(control->view_manager()->begin(), control->view_manager()->end(), [&download](View* v) { v->insert(download); }); - std::for_each(control->view_manager()->begin(), control->view_manager()->end(), [&download](View* v) { v->filter_download(download); }); + for (auto v : *control->view_manager()) + v->insert(download); + for (auto v : *control->view_manager()) + v->filter_download(download); DL_TRIGGER_EVENT(*itr, "event.download.inserted"); @@ -201,7 +203,8 @@ DownloadList::erase(iterator itr) { control->core()->download_store()->remove(*itr); DL_TRIGGER_EVENT(*itr, "event.download.erased"); - std::for_each(control->view_manager()->begin(), control->view_manager()->end(), [itr](View* v) { v->erase(*itr); }); + for (auto v : *control->view_manager()) + v->erase(*itr); torrent::download_remove(*(*itr)->download()); delete *itr; diff --git a/src/core/manager.cc b/src/core/manager.cc index 7ea05b8f..1e5355d4 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -142,9 +142,11 @@ Manager::cleanup() { void Manager::shutdown(bool force) { if (!force) - std::for_each(m_download_list->begin(), m_download_list->end(), [this](Download* d) { m_download_list->pause_default(d); }); + for (auto d : *m_download_list) + m_download_list->pause_default(d); else - std::for_each(m_download_list->begin(), m_download_list->end(), [this](Download* d) { m_download_list->close_quick(d); }); + for (auto d : *m_download_list) + m_download_list->close_quick(d); } void diff --git a/src/core/view_manager.cc b/src/core/view_manager.cc index 8c2c7669..8c1464f5 100644 --- a/src/core/view_manager.cc +++ b/src/core/view_manager.cc @@ -18,7 +18,8 @@ namespace core { void ViewManager::clear() { - std::for_each(begin(), end(), [](View* v) { delete v; }); + for (auto v : *this) + delete v; base_type::clear(); } diff --git a/src/display/text_element_list.cc b/src/display/text_element_list.cc index 5ebce03b..919262a8 100644 --- a/src/display/text_element_list.cc +++ b/src/display/text_element_list.cc @@ -45,7 +45,8 @@ namespace display { void TextElementList::clear() { - std::for_each(begin(), end(), [](TextElement* t) { delete t; }); + for (auto t : *this) + delete t; base_type::clear(); } diff --git a/src/display/window_text.cc b/src/display/window_text.cc index 14eec397..ddac86cb 100644 --- a/src/display/window_text.cc +++ b/src/display/window_text.cc @@ -16,7 +16,8 @@ WindowText::WindowText(rpc::target_type target, extent_type margin) : void WindowText::clear() { - std::for_each(begin(), end(), [](TextElement* text) { delete text; }); + for (auto t : *this) + delete t; base_type::clear(); delete m_errorHandler; diff --git a/src/input/path_input.cc b/src/input/path_input.cc index 8af9c328..d54c701b 100644 --- a/src/input/path_input.cc +++ b/src/input/path_input.cc @@ -68,17 +68,6 @@ PathInput::pressed(int key) { return true; } -struct _transform_filename { - void operator () (utils::directory_entry& entry) { -#ifdef __sun__ - if (entry.s_type & S_IFDIR) -#else - if (entry.s_type == DT_DIR) -#endif - entry.s_name += '/'; - } -}; - void PathInput::receive_do_complete() { lt_log_print(torrent::LOG_UI_EVENTS, "path_input: received completion"); @@ -93,7 +82,14 @@ PathInput::receive_do_complete() { return; } - std::for_each(dir.begin(), dir.end(), _transform_filename()); + for (auto& entry : dir) { +#ifdef __sun__ + if (entry.s_type & S_IFDIR) +#else + if (entry.s_type == DT_DIR) +#endif + entry.s_name += '/'; + } range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos())); diff --git a/src/rpc/command_scheduler.cc b/src/rpc/command_scheduler.cc index 168e2fff..798608f1 100644 --- a/src/rpc/command_scheduler.cc +++ b/src/rpc/command_scheduler.cc @@ -14,7 +14,8 @@ namespace rpc { CommandScheduler::~CommandScheduler() { - std::for_each(begin(), end(), [](CommandSchedulerItem* item) { delete item; }); + for (auto item : *this) + delete item; } CommandScheduler::iterator diff --git a/src/ui/element_peer_list.cc b/src/ui/element_peer_list.cc index ba66cbfc..410ce9a5 100644 --- a/src/ui/element_peer_list.cc +++ b/src/ui/element_peer_list.cc @@ -63,7 +63,8 @@ ElementPeerList::ElementPeerList(core::Download* d) : torrent::ConnectionList* connection_list = m_download->download()->connection_list(); - std::for_each(connection_list->begin(), connection_list->end(), [&](torrent::Peer* peer) { m_list.push_back(peer); }); + for (auto peer : *connection_list) + m_list.push_back(peer); m_peer_connected = connection_list->signal_connected().insert(connection_list->signal_connected().end(), std::bind(&ElementPeerList::receive_peer_connected, this, std::placeholders::_1)); diff --git a/test/helpers/utils.h b/test/helpers/utils.h index e81d22eb..de37e49c 100644 --- a/test/helpers/utils.h +++ b/test/helpers/utils.h @@ -6,21 +6,6 @@ #include #include -static void -dump_failure_log(const failure_type& failure) { - if (failure.log->empty()) - return; - - std::cout << std::endl << failure.name << std::endl; - - // Doesn't print dump messages as log_buffer drops them. - std::for_each(failure.log->begin(), failure.log->end(), [](const torrent::log_entry& entry) { - std::cout << entry.timestamp << ' ' << entry.message << '\n'; - }); - - std::cout << std::flush; -} - static void dump_failures(const failure_list_type& failures) { if (failures.empty()) @@ -31,9 +16,19 @@ dump_failures(const failure_list_type& failures) { << "Failed Test Logs:" << std::endl << "=================" << std::endl; - std::for_each(failures.begin(), failures.end(), [](const failure_type& failure) { - dump_failure_log(failure); - }); + for (const auto& failure : failures) { + if (failure.log->empty()) + return; + + std::cout << '\n' + << failure.name << '\n'; + + // Doesn't print dump messages as log_buffer drops them. + for (const auto& entry : *failure.log) + std::cout << entry.timestamp << ' ' << entry.message << '\n'; + + std::cout << std::flush; + } std::cout << std::endl; }