mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
remove some transform calls
for range loop is more readable. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
committed by
Jari Sundell
parent
64cb3d11a0
commit
47089bce70
@@ -353,9 +353,8 @@ f_multicall(core::Download* download, const torrent::Object::list_type& args) {
|
||||
bool use_regex = true;
|
||||
|
||||
if (args.front().is_list())
|
||||
std::transform(args.front().as_list().begin(), args.front().as_list().end(),
|
||||
std::back_inserter(regex_list),
|
||||
std::bind(&torrent::Object::as_string_c, std::placeholders::_1));
|
||||
for (const auto& o : args.front().as_list())
|
||||
regex_list.push_back(o.as_string_c());
|
||||
else if (args.front().is_string() && !args.front().as_string().empty())
|
||||
regex_list.push_back(args.front().as_string());
|
||||
else
|
||||
|
||||
+6
-6
@@ -408,16 +408,16 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
itr->update((r.pattern()[0] != '.') ? utils::Directory::update_hide_dot : 0);
|
||||
itr->erase(std::remove_if(itr->begin(), itr->end(), [r](const utils::directory_entry& entry) { return !r(entry.s_name); }), itr->end());
|
||||
|
||||
std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), [itr](const utils::directory_entry& entry) {
|
||||
return path_expand_transform(itr->path() + (itr->path() == "/" ? "" : "/"), entry);
|
||||
});
|
||||
for (const auto& cache : *itr)
|
||||
nextCache.push_back(path_expand_transform(itr->path() + (itr->path() == "/" ? "" : "/"), cache));
|
||||
}
|
||||
|
||||
currentCache.clear();
|
||||
currentCache.swap(nextCache);
|
||||
}
|
||||
|
||||
std::transform(currentCache.begin(), currentCache.end(), std::back_inserter(*paths), std::mem_fn(&utils::Directory::path));
|
||||
for (const auto& cache : currentCache)
|
||||
paths->push_back(cache.path());
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -450,8 +450,8 @@ Manager::try_create_download_expand(const std::string& uri, int flags, command_l
|
||||
// hashing view and starts hashing if nessesary.
|
||||
void
|
||||
Manager::receive_hashing_changed() {
|
||||
bool foundHashing = std::find_if(m_hashingView->begin_visible(), m_hashingView->end_visible(),
|
||||
std::mem_fn(&Download::is_hash_checking)) != m_hashingView->end_visible();
|
||||
bool foundHashing = std::any_of(m_hashingView->begin_visible(), m_hashingView->end_visible(),
|
||||
std::mem_fn(&Download::is_hash_checking));
|
||||
|
||||
// Try quick hashing all those with hashing == initial, set them to
|
||||
// something else when failed.
|
||||
|
||||
+4
-6
@@ -70,9 +70,8 @@ object_to_json(const torrent::Object& object) noexcept {
|
||||
return object.as_string();
|
||||
case torrent::Object::TYPE_LIST: {
|
||||
json result = json::array();
|
||||
std::transform(object.as_list().cbegin(), object.as_list().cend(), std::back_inserter(result), [](const torrent::Object& element) {
|
||||
return object_to_json(element);
|
||||
});
|
||||
for (const auto& obj : object.as_list())
|
||||
result.push_back(object_to_json(obj));
|
||||
return result;
|
||||
}
|
||||
case torrent::Object::TYPE_MAP: {
|
||||
@@ -88,9 +87,8 @@ object_to_json(const torrent::Object& object) noexcept {
|
||||
|
||||
const auto& dict_obj = object.as_dict_obj();
|
||||
if (dict_obj.is_list()) {
|
||||
std::transform(dict_obj.as_list().cbegin(), dict_obj.as_list().cend(), std::back_inserter(result), [](const torrent::Object& element) {
|
||||
return object_to_json(element);
|
||||
});
|
||||
for (const auto& element : dict_obj.as_list())
|
||||
result.push_back(object_to_json(element));
|
||||
} else {
|
||||
result.push_back(object_to_json(dict_obj));
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ object_storage::rlookup_list(const std::string& cmd_key) {
|
||||
rlookup_iterator r_itr = m_rlookup.find(cmd_key);
|
||||
|
||||
if (r_itr != m_rlookup.end())
|
||||
std::transform(r_itr->second.begin(), r_itr->second.end(), std::back_inserter(result),
|
||||
std::bind(&key_type::c_str, std::bind(std::mem_fn(&value_type::first), std::placeholders::_1)));
|
||||
for (auto pair : r_itr->second)
|
||||
result.push_back(pair->first.c_str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
bool is_valid() const;
|
||||
|
||||
const std::string& path() { return m_path; }
|
||||
const std::string& path() const { return m_path; }
|
||||
void set_path(const std::string& path) { m_path = path; }
|
||||
|
||||
bool update(int flags);
|
||||
|
||||
Reference in New Issue
Block a user