mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-22 09:06:18 +00:00
replace for_each with range loops
No advantage over the latter, which is simpler. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
committed by
Jari Sundell
parent
8b663dd169
commit
84c0d516ef
@@ -286,9 +286,8 @@ DownloadFactory::receive_success() {
|
|||||||
if (torrent::log_groups[torrent::LOG_TORRENT_DEBUG].valid())
|
if (torrent::log_groups[torrent::LOG_TORRENT_DEBUG].valid())
|
||||||
log_created(download, rtorrent);
|
log_created(download, rtorrent);
|
||||||
|
|
||||||
std::for_each(m_commands.begin(), m_commands.end(), [&download](const std::string& cmd) {
|
for (const auto& command : m_commands)
|
||||||
rpc::parse_command_multiple_std(cmd, rpc::make_target(download));
|
rpc::parse_command_multiple_std(command, rpc::make_target(download));
|
||||||
});
|
|
||||||
|
|
||||||
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
|
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
|
||||||
throw torrent::input_error("The newly created download was removed.");
|
throw torrent::input_error("The newly created download was removed.");
|
||||||
|
|||||||
@@ -167,8 +167,10 @@ DownloadList::insert(Download* download) {
|
|||||||
|
|
||||||
// This needs to be separated into two different calls to ensure
|
// This needs to be separated into two different calls to ensure
|
||||||
// the download remains in the view.
|
// the download remains in the view.
|
||||||
std::for_each(control->view_manager()->begin(), control->view_manager()->end(), [&download](View* v) { v->insert(download); });
|
for (auto v : *control->view_manager())
|
||||||
std::for_each(control->view_manager()->begin(), control->view_manager()->end(), [&download](View* v) { v->filter_download(download); });
|
v->insert(download);
|
||||||
|
for (auto v : *control->view_manager())
|
||||||
|
v->filter_download(download);
|
||||||
|
|
||||||
DL_TRIGGER_EVENT(*itr, "event.download.inserted");
|
DL_TRIGGER_EVENT(*itr, "event.download.inserted");
|
||||||
|
|
||||||
@@ -201,7 +203,8 @@ DownloadList::erase(iterator itr) {
|
|||||||
control->core()->download_store()->remove(*itr);
|
control->core()->download_store()->remove(*itr);
|
||||||
|
|
||||||
DL_TRIGGER_EVENT(*itr, "event.download.erased");
|
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());
|
torrent::download_remove(*(*itr)->download());
|
||||||
delete *itr;
|
delete *itr;
|
||||||
|
|||||||
+4
-2
@@ -142,9 +142,11 @@ Manager::cleanup() {
|
|||||||
void
|
void
|
||||||
Manager::shutdown(bool force) {
|
Manager::shutdown(bool force) {
|
||||||
if (!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
|
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
|
void
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ namespace core {
|
|||||||
|
|
||||||
void
|
void
|
||||||
ViewManager::clear() {
|
ViewManager::clear() {
|
||||||
std::for_each(begin(), end(), [](View* v) { delete v; });
|
for (auto v : *this)
|
||||||
|
delete v;
|
||||||
|
|
||||||
base_type::clear();
|
base_type::clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ namespace display {
|
|||||||
|
|
||||||
void
|
void
|
||||||
TextElementList::clear() {
|
TextElementList::clear() {
|
||||||
std::for_each(begin(), end(), [](TextElement* t) { delete t; });
|
for (auto t : *this)
|
||||||
|
delete t;
|
||||||
base_type::clear();
|
base_type::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ WindowText::WindowText(rpc::target_type target, extent_type margin) :
|
|||||||
|
|
||||||
void
|
void
|
||||||
WindowText::clear() {
|
WindowText::clear() {
|
||||||
std::for_each(begin(), end(), [](TextElement* text) { delete text; });
|
for (auto t : *this)
|
||||||
|
delete t;
|
||||||
base_type::clear();
|
base_type::clear();
|
||||||
|
|
||||||
delete m_errorHandler;
|
delete m_errorHandler;
|
||||||
|
|||||||
+8
-12
@@ -68,17 +68,6 @@ PathInput::pressed(int key) {
|
|||||||
return true;
|
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
|
void
|
||||||
PathInput::receive_do_complete() {
|
PathInput::receive_do_complete() {
|
||||||
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: received completion");
|
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: received completion");
|
||||||
@@ -93,7 +82,14 @@ PathInput::receive_do_complete() {
|
|||||||
return;
|
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()));
|
range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
namespace rpc {
|
namespace rpc {
|
||||||
|
|
||||||
CommandScheduler::~CommandScheduler() {
|
CommandScheduler::~CommandScheduler() {
|
||||||
std::for_each(begin(), end(), [](CommandSchedulerItem* item) { delete item; });
|
for (auto item : *this)
|
||||||
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandScheduler::iterator
|
CommandScheduler::iterator
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ ElementPeerList::ElementPeerList(core::Download* d) :
|
|||||||
|
|
||||||
torrent::ConnectionList* connection_list = m_download->download()->connection_list();
|
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(),
|
m_peer_connected = connection_list->signal_connected().insert(connection_list->signal_connected().end(),
|
||||||
std::bind(&ElementPeerList::receive_peer_connected, this, std::placeholders::_1));
|
std::bind(&ElementPeerList::receive_peer_connected, this, std::placeholders::_1));
|
||||||
|
|||||||
+13
-18
@@ -6,21 +6,6 @@
|
|||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <torrent/utils/log.h>
|
#include <torrent/utils/log.h>
|
||||||
|
|
||||||
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
|
static void
|
||||||
dump_failures(const failure_list_type& failures) {
|
dump_failures(const failure_list_type& failures) {
|
||||||
if (failures.empty())
|
if (failures.empty())
|
||||||
@@ -31,9 +16,19 @@ dump_failures(const failure_list_type& failures) {
|
|||||||
<< "Failed Test Logs:" << std::endl
|
<< "Failed Test Logs:" << std::endl
|
||||||
<< "=================" << std::endl;
|
<< "=================" << std::endl;
|
||||||
|
|
||||||
std::for_each(failures.begin(), failures.end(), [](const failure_type& failure) {
|
for (const auto& failure : failures) {
|
||||||
dump_failure_log(failure);
|
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;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user