mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-05 05:39:22 +00:00
clang-tidy: convert loops to range based
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
committed by
Jari Sundell
parent
bb8d677f6e
commit
0948b5f86a
+10
-11
@@ -265,12 +265,12 @@ retrieve_d_custom_map(core::Download* download, bool keys_only, const torrent::O
|
||||
throw torrent::bencode_error("d.custom.keys/items takes no arguments.");
|
||||
|
||||
torrent::Object result = keys_only ? torrent::Object::create_list() : torrent::Object::create_map();
|
||||
torrent::Object::map_type& entries = download->bencode()->get_key("rtorrent").get_key("custom").as_map();
|
||||
|
||||
for (torrent::Object::map_type::const_iterator itr = entries.begin(), last = entries.end(); itr != last; itr++) {
|
||||
if (keys_only) result.as_list().push_back(itr->first);
|
||||
else result.as_map()[itr->first] = itr->second;
|
||||
}
|
||||
for (const auto& entry : download->bencode()->get_key("rtorrent").get_key("custom").as_map())
|
||||
if (keys_only)
|
||||
result.as_list().push_back(entry.first);
|
||||
else
|
||||
result.as_map()[entry.first] = entry.second;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -360,16 +360,16 @@ f_multicall(core::Download* download, const torrent::Object::list_type& args) {
|
||||
else
|
||||
use_regex = false;
|
||||
|
||||
for (torrent::FileList::const_iterator itr = download->file_list()->begin(), last = download->file_list()->end(); itr != last; itr++) {
|
||||
for (const auto& file : *download->file_list()) {
|
||||
if (use_regex &&
|
||||
std::none_of(regex_list.begin(), regex_list.end(), [itr](const auto& r) { return r((*itr)->path()->as_string()); }))
|
||||
std::none_of(regex_list.begin(), regex_list.end(), [&file](const auto& r) { return r(file->path()->as_string()); }))
|
||||
continue;
|
||||
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
|
||||
|
||||
for (torrent::Object::list_const_iterator cItr = ++args.begin(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
row.push_back(rpc::parse_command(rpc::make_target(itr->get()), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
row.push_back(rpc::parse_command(rpc::make_target(file.get()), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,14 +419,13 @@ p_multicall(core::Download* download, const torrent::Object::list_type& args) {
|
||||
torrent::Object resultRaw = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = resultRaw.as_list();
|
||||
|
||||
for (torrent::ConnectionList::const_iterator itr = download->connection_list()->begin(), last = download->connection_list()->end();
|
||||
itr != last; itr++) {
|
||||
for (const auto& connection : *download->connection_list()) {
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
|
||||
|
||||
for (torrent::Object::list_const_iterator cItr = ++args.begin(); cItr != args.end(); cItr++) {
|
||||
const std::string& cmd = cItr->as_string();
|
||||
|
||||
row.push_back(rpc::parse_command(rpc::make_target(*itr), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
row.push_back(rpc::parse_command(rpc::make_target(connection), cmd.c_str(), cmd.c_str() + cmd.size()).first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ static std::vector<std::pair<const char*, int>> object_storage_flags = {
|
||||
|
||||
static int
|
||||
object_storage_parse_flag(const std::string& flag) {
|
||||
for (auto f : object_storage_flags)
|
||||
if (f.first == flag)
|
||||
return f.second;
|
||||
for (auto [n, f] : object_storage_flags)
|
||||
if (n == flag)
|
||||
return f;
|
||||
|
||||
throw torrent::input_error("unknown flag");
|
||||
}
|
||||
@@ -380,13 +380,11 @@ system_method_set_key(const torrent::Object::list_type& args) {
|
||||
|
||||
torrent::Object
|
||||
system_method_list_keys(const torrent::Object::string_type& args) {
|
||||
const torrent::Object::map_type& multi_cmd = control->object_storage()->get_str(args).as_map();
|
||||
|
||||
torrent::Object rawResult = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = rawResult.as_list();
|
||||
|
||||
for (torrent::Object::map_const_iterator itr = multi_cmd.begin(), last = multi_cmd.end(); itr != last; itr++)
|
||||
result.push_back(itr->first);
|
||||
for (const auto& itr : control->object_storage()->get_str(args).as_map())
|
||||
result.push_back(itr.first);
|
||||
|
||||
return rawResult;
|
||||
}
|
||||
|
||||
+17
-19
@@ -55,23 +55,23 @@ apply_on_ratio(const torrent::Object& rawArgs) {
|
||||
|
||||
auto ratio_command = "group." + group_name + ".ratio.command";
|
||||
|
||||
for (std::vector<core::Download*>::iterator itr = downloads.begin(), last = downloads.end(); itr != last; itr++)
|
||||
rpc::commands.call_catch(ratio_command, rpc::make_target(*itr), torrent::Object(), "Ratio reached, but command failed: ");
|
||||
for (const auto& download : downloads)
|
||||
rpc::commands.call_catch(ratio_command, rpc::make_target(download), torrent::Object(), "Ratio reached, but command failed: ");
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_start_tied() {
|
||||
for (auto itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(*itr)) == 1)
|
||||
for (const auto& download : *control->core()->download_list()) {
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 1)
|
||||
continue;
|
||||
|
||||
rak::file_stat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (!tied_to_file.empty() && fs.update(rak::path_expand(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_start=");
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_start=");
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
@@ -79,15 +79,15 @@ apply_start_tied() {
|
||||
|
||||
torrent::Object
|
||||
apply_stop_untied() {
|
||||
for (auto itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(*itr)) == 0)
|
||||
for (const auto& download : *control->core()->download_list()) {
|
||||
if (rpc::call_command_value("d.state", rpc::make_target(download)) == 0)
|
||||
continue;
|
||||
|
||||
rak::file_stat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (!tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_stop=");
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_stop=");
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
@@ -95,12 +95,12 @@ apply_stop_untied() {
|
||||
|
||||
torrent::Object
|
||||
apply_close_untied() {
|
||||
for (auto itr = control->core()->download_list()->begin(); itr != control->core()->download_list()->end(); ++itr) {
|
||||
for (const auto& download : *control->core()->download_list()) {
|
||||
rak::file_stat fs;
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(*itr));
|
||||
const std::string& tied_to_file = rpc::call_command_string("d.tied_to_file", rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(*itr)) == 0 && !tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(*itr), "d.try_close=");
|
||||
if (rpc::call_command_value("d.ignore_commands", rpc::make_target(download)) == 0 && !tied_to_file.empty() && !fs.update(rak::path_expand(tied_to_file)))
|
||||
rpc::parse_command_single(rpc::make_target(download), "d.try_close=");
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
@@ -234,9 +234,7 @@ d_multicall(const torrent::Object::list_type& args) {
|
||||
|
||||
// Add some pre-parsing of the commands, so we don't spend time
|
||||
// parsing and searching command map for every single call.
|
||||
std::vector<core::Download*> dlist((*view_itr)->size_visible());
|
||||
|
||||
std::copy((*view_itr)->begin_visible(), (*view_itr)->end_visible(), dlist.data());
|
||||
std::vector<core::Download*> dlist((*view_itr)->begin_visible(), (*view_itr)->end_visible());
|
||||
|
||||
torrent::Object resultRaw = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = resultRaw.as_list();
|
||||
@@ -275,14 +273,14 @@ d_multicall_filtered(const torrent::Object::list_type& args) {
|
||||
torrent::Object::list_type& result = resultRaw.as_list();
|
||||
++arg; // skip to first command
|
||||
|
||||
for (core::View::iterator item = dlist.begin(); item != dlist.end(); ++item) {
|
||||
for (const auto& item : dlist) {
|
||||
// Add empty row to result
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
|
||||
|
||||
// Call the provided commands and assemble their results
|
||||
for (torrent::Object::list_const_iterator command = arg; command != args.end(); command++) {
|
||||
auto& cmdstr = command->as_string();
|
||||
row.push_back(rpc::parse_command(rpc::make_target(*item), cmdstr.c_str(), cmdstr.c_str() + cmdstr.size()).first);
|
||||
row.push_back(rpc::parse_command(rpc::make_target(item), cmdstr.c_str(), cmdstr.c_str() + cmdstr.size()).first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -76,8 +76,8 @@ apply_f_path_components(torrent::File* file) {
|
||||
torrent::Object resultRaw = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = resultRaw.as_list();
|
||||
|
||||
for (torrent::Path::const_iterator itr = file->path()->begin(), last = file->path()->end(); itr != last; itr++)
|
||||
result.push_back(*itr);
|
||||
for (const auto& itr : *file->path())
|
||||
result.push_back(itr);
|
||||
|
||||
return resultRaw;
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ typedef torrent::FileManager FM_t;
|
||||
torrent::Object
|
||||
apply_pieces_stats_total_size() {
|
||||
uint64_t size = 0;
|
||||
core::DownloadList* d_list = control->core()->download_list();
|
||||
|
||||
for (core::DownloadList::iterator itr = d_list->begin(), last = d_list->end(); itr != last; itr++)
|
||||
if ((*itr)->is_active())
|
||||
size += (*itr)->file_list()->size_bytes();
|
||||
for (const auto& d : *control->core()->download_list())
|
||||
if (d->is_active())
|
||||
size += d->file_list()->size_bytes();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -108,19 +108,18 @@ apply_log(const torrent::Object::string_type& arg, int logType) {
|
||||
|
||||
torrent::Object
|
||||
log_vmmap_dump(const std::string& str) {
|
||||
core::DownloadList* d_list = control->core()->download_list();
|
||||
std::vector<torrent::vm_mapping> all_mappings;
|
||||
|
||||
for (core::DownloadList::iterator itr = d_list->begin(), last = d_list->end(); itr != last; itr++) {
|
||||
std::vector<torrent::vm_mapping> tmp_mappings = torrent::chunk_list_mapping((*itr)->download());
|
||||
for (const auto& d : *control->core()->download_list()) {
|
||||
std::vector<torrent::vm_mapping> tmp_mappings = torrent::chunk_list_mapping(d->download());
|
||||
|
||||
all_mappings.insert(all_mappings.end(), tmp_mappings.begin(), tmp_mappings.end());
|
||||
all_mappings.insert(all_mappings.end(), tmp_mappings.begin(), tmp_mappings.end());
|
||||
}
|
||||
|
||||
FILE* log_file = fopen(str.c_str(), "w");
|
||||
|
||||
for (std::vector<torrent::vm_mapping>::iterator itr = all_mappings.begin(), last = all_mappings.end(); itr != last; itr++) {
|
||||
fprintf(log_file, "%8p-%8p [%5llxk]\n", itr->ptr, (char*)itr->ptr + itr->length, (long long unsigned int)(itr->length / 1024));
|
||||
for (auto& all_mapping : all_mappings) {
|
||||
fprintf(log_file, "%8p-%8p [%5llxk]\n", all_mapping.ptr, (char*)all_mapping.ptr + all_mapping.length, (long long unsigned int)(all_mapping.length / 1024));
|
||||
}
|
||||
|
||||
fclose(log_file);
|
||||
|
||||
@@ -30,8 +30,8 @@ torrent::Object
|
||||
apply_encryption(const torrent::Object::list_type& args) {
|
||||
uint32_t options_mask = torrent::ConnectionManager::encryption_none;
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
uint32_t opt = torrent::option_find_string(torrent::OPTION_ENCRYPTION, itr->as_string().c_str());
|
||||
for (const auto& arg : args) {
|
||||
uint32_t opt = torrent::option_find_string(torrent::OPTION_ENCRYPTION, arg.as_string().c_str());
|
||||
|
||||
if (opt == torrent::ConnectionManager::encryption_none)
|
||||
options_mask = torrent::ConnectionManager::encryption_none;
|
||||
@@ -90,11 +90,12 @@ initialize_rpc() {
|
||||
|
||||
unsigned int count = 0;
|
||||
|
||||
for (rpc::CommandMap::const_iterator itr = rpc::commands.begin(), last = rpc::commands.end(); itr != last; itr++, count++) {
|
||||
if (!(itr->second.m_flags & rpc::CommandMap::flag_public_rpc))
|
||||
for (const auto& [name, cmd] : rpc::commands) {
|
||||
if (!(cmd.m_flags & rpc::CommandMap::flag_public_rpc))
|
||||
continue;
|
||||
|
||||
rpc::rpc.insert_command(itr->first.c_str(), itr->second.m_parm, itr->second.m_doc);
|
||||
rpc::rpc.insert_command(name.c_str(), cmd.m_parm, cmd.m_doc);
|
||||
++count;
|
||||
}
|
||||
|
||||
lt_log_print(torrent::LOG_RPC_EVENTS, "RPC initialized with %u functions.", count);
|
||||
|
||||
+11
-11
@@ -63,22 +63,22 @@ apply_dht_add_node(const std::string& arg) {
|
||||
torrent::Object
|
||||
apply_enable_trackers(int64_t arg) {
|
||||
if (arg == 0) {
|
||||
for (auto itr : *control->core()->download_list())
|
||||
itr->tracker_controller().for_each([](auto& tracker) { tracker.disable(); });
|
||||
for (auto download : *control->core()->download_list())
|
||||
download->tracker_controller().for_each([](auto& tracker) { tracker.disable(); });
|
||||
|
||||
} else if (rpc::call_command_value("trackers.use_udp") == 0) {
|
||||
for (auto itr : *control->core()->download_list()) {
|
||||
itr->tracker_controller().for_each([](auto& tracker) {
|
||||
if (tracker.type() == torrent::TRACKER_UDP)
|
||||
tracker.disable();
|
||||
else
|
||||
tracker.enable();
|
||||
});
|
||||
for (auto download : *control->core()->download_list()) {
|
||||
download->tracker_controller().for_each([](auto& tracker) {
|
||||
if (tracker.type() == torrent::TRACKER_UDP)
|
||||
tracker.disable();
|
||||
else
|
||||
tracker.enable();
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
for (auto itr : *control->core()->download_list())
|
||||
itr->tracker_controller().for_each([](auto& tracker) { tracker.enable(); });
|
||||
for (auto download : *control->core()->download_list())
|
||||
download->tracker_controller().for_each([](auto& tracker) { tracker.enable(); });
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
|
||||
+30
-32
@@ -75,8 +75,8 @@ apply_view_list() {
|
||||
torrent::Object rawResult = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = rawResult.as_list();
|
||||
|
||||
for (core::ViewManager::const_iterator itr = control->view_manager()->begin(), last = control->view_manager()->end(); itr != last; itr++)
|
||||
result.push_back((*itr)->name());
|
||||
for (auto itr : *control->view_manager())
|
||||
result.push_back(itr->name());
|
||||
|
||||
return rawResult;
|
||||
}
|
||||
@@ -193,18 +193,18 @@ apply_and(rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
if (rawArgs.type() != torrent::Object::TYPE_LIST)
|
||||
return as_boolean(rawArgs);
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = rawArgs.as_list().begin(), last = rawArgs.as_list().end(); itr != last; itr++)
|
||||
if (itr->is_dict_key()) {
|
||||
if (!as_boolean(rpc::commands.call_command(itr->as_dict_key().c_str(), itr->as_dict_obj(), target)))
|
||||
for (const auto& itr : rawArgs.as_list())
|
||||
if (itr.is_dict_key()) {
|
||||
if (!as_boolean(rpc::commands.call_command(itr.as_dict_key().c_str(), itr.as_dict_obj(), target)))
|
||||
return (int64_t)false;
|
||||
|
||||
} else if (itr->is_value()) {
|
||||
if (!itr->as_value())
|
||||
} else if (itr.is_value()) {
|
||||
if (!itr.as_value())
|
||||
return (int64_t)false;
|
||||
|
||||
} else {
|
||||
// TODO: Switch to new versions that only accept the new command syntax.
|
||||
if (!as_boolean(rpc::parse_command_single(target, itr->as_string())))
|
||||
if (!as_boolean(rpc::parse_command_single(target, itr.as_string())))
|
||||
return (int64_t)false;
|
||||
}
|
||||
|
||||
@@ -216,17 +216,17 @@ apply_or(rpc::target_type target, const torrent::Object& rawArgs) {
|
||||
if (rawArgs.type() != torrent::Object::TYPE_LIST)
|
||||
return as_boolean(rawArgs);
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = rawArgs.as_list().begin(), last = rawArgs.as_list().end(); itr != last; itr++)
|
||||
if (itr->is_dict_key()) {
|
||||
if (as_boolean(rpc::commands.call_command(itr->as_dict_key().c_str(), itr->as_dict_obj(), target)))
|
||||
for (const auto& itr : rawArgs.as_list())
|
||||
if (itr.is_dict_key()) {
|
||||
if (as_boolean(rpc::commands.call_command(itr.as_dict_key().c_str(), itr.as_dict_obj(), target)))
|
||||
return (int64_t)true;
|
||||
|
||||
} else if (itr->is_value()) {
|
||||
if (itr->as_value())
|
||||
} else if (itr.is_value()) {
|
||||
if (itr.as_value())
|
||||
return (int64_t)true;
|
||||
|
||||
} else {
|
||||
if (as_boolean(rpc::parse_command_single(target, itr->as_string())))
|
||||
if (as_boolean(rpc::parse_command_single(target, itr.as_string())))
|
||||
return (int64_t)true;
|
||||
}
|
||||
|
||||
@@ -526,9 +526,9 @@ apply_if(rpc::target_type target, const torrent::Object& rawArgs, int flags) {
|
||||
// nice to have a parse_command function that takes list
|
||||
// iterator...
|
||||
|
||||
for (torrent::Object::list_type::const_iterator cmdItr = itr->as_list().begin(), last = itr->as_list().end(); cmdItr != last; cmdItr++)
|
||||
if (cmdItr->is_string())
|
||||
rpc::parse_command(target, cmdItr->as_string().c_str(), cmdItr->as_string().c_str() + cmdItr->as_string().size());
|
||||
for (const auto& cmdItr : itr->as_list())
|
||||
if (cmdItr.is_string())
|
||||
rpc::parse_command(target, cmdItr.as_string().c_str(), cmdItr.as_string().c_str() + cmdItr.as_string().size());
|
||||
|
||||
return torrent::Object();
|
||||
|
||||
@@ -630,19 +630,18 @@ as_vector(const torrent::Object::list_type& args) {
|
||||
|
||||
std::vector<int64_t> result;
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
for (const auto& arg : args) {
|
||||
|
||||
if (itr->is_value()) {
|
||||
result.push_back(itr->as_value());
|
||||
} else if (itr->is_string()) {
|
||||
result.push_back(rpc::convert_to_value(itr->as_string()));
|
||||
} else if (itr->is_list()) {
|
||||
std::vector<int64_t> subResult = as_vector(itr->as_list());
|
||||
if (arg.is_value()) {
|
||||
result.push_back(arg.as_value());
|
||||
} else if (arg.is_string()) {
|
||||
result.push_back(rpc::convert_to_value(arg.as_string()));
|
||||
} else if (arg.is_list()) {
|
||||
std::vector<int64_t> subResult = as_vector(arg.as_list());
|
||||
result.insert(result.end(), subResult.begin(), subResult.end());
|
||||
} else {
|
||||
throw torrent::input_error("Wrong type supplied to as_vector.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -711,20 +710,19 @@ apply_arith_count(const torrent::Object::list_type& args) {
|
||||
|
||||
int64_t val = 0;
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
for (const auto& arg : args) {
|
||||
|
||||
switch (itr->type()) {
|
||||
switch (arg.type()) {
|
||||
case torrent::Object::TYPE_VALUE:
|
||||
case torrent::Object::TYPE_STRING:
|
||||
val++;
|
||||
break;
|
||||
case torrent::Object::TYPE_LIST:
|
||||
val += apply_arith_count(itr->as_list());
|
||||
val += apply_arith_count(arg.as_list());
|
||||
break;
|
||||
default:
|
||||
throw torrent::input_error("Wrong type supplied to apply_arith_count.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return val;
|
||||
@@ -752,9 +750,9 @@ cmd_status_throttle_names(bool up, const torrent::Object::list_type& args) {
|
||||
|
||||
std::vector<std::string> throttle_name_list;
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; itr++) {
|
||||
if (itr->is_string())
|
||||
throttle_name_list.push_back(itr->as_string());
|
||||
for (const auto& arg : args) {
|
||||
if (arg.is_string())
|
||||
throttle_name_list.push_back(arg.as_string());
|
||||
}
|
||||
|
||||
if (up)
|
||||
|
||||
@@ -191,8 +191,8 @@ DownloadFactory::receive_success() {
|
||||
|
||||
torrent::Object::list_type& commands = meta.insert_key("commands", torrent::Object::create_list()).as_list();
|
||||
|
||||
for (command_list_type::iterator itr = m_commands.begin(); itr != m_commands.end(); ++itr)
|
||||
commands.push_back(*itr);
|
||||
for (auto& m_command : m_commands)
|
||||
commands.push_back(m_command);
|
||||
}
|
||||
|
||||
if (m_session) {
|
||||
@@ -333,8 +333,8 @@ DownloadFactory::log_created(Download* download, torrent::Object* rtorrent) {
|
||||
|
||||
dump << "---COMMANDS---" << std::endl;
|
||||
|
||||
for (command_list_type::const_iterator itr = m_commands.begin(); itr != m_commands.end(); itr++) {
|
||||
dump << *itr << std::endl;
|
||||
for (const auto& m_command : m_commands) {
|
||||
dump << m_command << std::endl;
|
||||
}
|
||||
|
||||
std::string dump_str = dump.str();
|
||||
|
||||
+9
-9
@@ -348,8 +348,8 @@ Manager::try_create_download_from_meta_download(torrent::Object* bencode, const
|
||||
|
||||
torrent::Object& meta = bencode->get_key("rtorrent_meta_download");
|
||||
torrent::Object::list_type& commands = meta.get_key_list("commands");
|
||||
for (torrent::Object::list_type::const_iterator itr = commands.begin(); itr != commands.end(); ++itr)
|
||||
f->commands().insert(f->commands().end(), itr->as_string());
|
||||
for (const auto& command : commands)
|
||||
f->commands().insert(f->commands().end(), command.as_string());
|
||||
|
||||
f->set_start(meta.get_key_value("start"));
|
||||
f->set_print_log(meta.get_key_value("print_log"));
|
||||
@@ -402,14 +402,14 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
|
||||
// Special case for ".."?
|
||||
|
||||
for (std::vector<utils::Directory>::iterator itr = currentCache.begin(); itr != currentCache.end(); ++itr) {
|
||||
for (auto& itr : currentCache) {
|
||||
// Only include filenames starting with '.' if the pattern
|
||||
// starts with the same.
|
||||
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());
|
||||
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());
|
||||
|
||||
for (const auto& cache : *itr)
|
||||
nextCache.push_back(path_expand_transform(itr->path() + (itr->path() == "/" ? "" : "/"), cache));
|
||||
for (const auto& cache : itr)
|
||||
nextCache.push_back(path_expand_transform(itr.path() + (itr.path() == "/" ? "" : "/"), cache));
|
||||
}
|
||||
|
||||
currentCache.clear();
|
||||
@@ -438,8 +438,8 @@ Manager::try_create_download_expand(const std::string& uri, int flags, command_l
|
||||
path_expand(&paths, uri);
|
||||
|
||||
if (!paths.empty())
|
||||
for (std::vector<std::string>::iterator itr = paths.begin(); itr != paths.end(); ++itr)
|
||||
try_create_download(*itr, flags, commands);
|
||||
for (auto& path : paths)
|
||||
try_create_download(path, flags, commands);
|
||||
|
||||
else
|
||||
try_create_download(uri, flags, commands);
|
||||
|
||||
+4
-5
@@ -118,8 +118,8 @@ View::emit_changed() {
|
||||
|
||||
void
|
||||
View::emit_changed_now() {
|
||||
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
for (auto& itr : m_signal_changed)
|
||||
itr();
|
||||
}
|
||||
|
||||
View::~View() {
|
||||
@@ -138,12 +138,11 @@ View::initialize(const std::string& name) {
|
||||
if (name.empty())
|
||||
throw torrent::internal_error("View::initialize(...) called with an empty name.");
|
||||
|
||||
core::DownloadList* dlist = control->core()->download_list();
|
||||
|
||||
m_name = name;
|
||||
|
||||
// Urgh, wrong. No filtering being done.
|
||||
std::for_each(dlist->begin(), dlist->end(), [&](Download* d) { push_back(d); });
|
||||
for (const auto& d : *control->core()->download_list())
|
||||
push_back(d);
|
||||
|
||||
m_size = base_type::size();
|
||||
m_focus = 0;
|
||||
|
||||
@@ -88,8 +88,8 @@ ViewManager::set_filter_on(const std::string& name, const filter_args& args) {
|
||||
|
||||
// TODO: Ensure the filter keys are rlookup.
|
||||
|
||||
for (filter_args::const_iterator itr = args.begin(); itr != args.end(); ++itr)
|
||||
(*viewItr)->set_filter_on_event(*itr);
|
||||
for (const auto& arg : args)
|
||||
(*viewItr)->set_filter_on_event(arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ TextElementList::print(char* first, char* last, Canvas::attributes_list* attribu
|
||||
|
||||
// Call print for each element even if first == last so that any
|
||||
// attributes gets added to the list.
|
||||
for (iterator itr = begin(); itr != end(); ++itr)
|
||||
for (auto& itr : *this)
|
||||
if (column-- > 0) {
|
||||
char* columnEnd = std::min(last, first + *m_columnWidth);
|
||||
|
||||
if (columnEnd < first || columnEnd > last)
|
||||
throw torrent::internal_error("TextElementList::print(...) columnEnd < first || columnEnd > last.");
|
||||
|
||||
first = (*itr)->print(first, columnEnd, attributes, target);
|
||||
first = itr->print(first, columnEnd, attributes, target);
|
||||
|
||||
if (first > columnEnd)
|
||||
throw torrent::internal_error("TextElementList::print(...) first > columnEnd.");
|
||||
@@ -71,7 +71,7 @@ TextElementList::print(char* first, char* last, Canvas::attributes_list* attribu
|
||||
first = columnEnd;
|
||||
|
||||
} else {
|
||||
first = (*itr)->print(first, last, attributes, target);
|
||||
first = itr->print(first, last, attributes, target);
|
||||
}
|
||||
|
||||
return first;
|
||||
@@ -82,15 +82,15 @@ TextElementList::max_length() {
|
||||
extent_type length = 0;
|
||||
int column = m_columnWidth != NULL ? m_column : 0;
|
||||
|
||||
for (iterator itr = begin(); itr != end(); ++itr) {
|
||||
extent_type l = column-- > 0 ? std::min((*itr)->max_length(), *m_columnWidth) : (*itr)->max_length();
|
||||
for (auto& itr : *this) {
|
||||
extent_type l = column-- > 0 ? std::min(itr->max_length(), *m_columnWidth) : itr->max_length();
|
||||
|
||||
if (l == extent_full)
|
||||
return extent_full;
|
||||
|
||||
length += l;
|
||||
}
|
||||
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,15 +295,14 @@ print_status_throttle_limit(char* first, char* last, bool up, const ui::Throttle
|
||||
char* firstc = throttle_str;
|
||||
char* lastc = throttle_str + 40 - 1;
|
||||
|
||||
for (ui::ThrottleNameList::const_iterator itr = throttle_names.begin(), laste = throttle_names.end(); itr != laste; itr++) {
|
||||
for (const auto& throttle_name : throttle_names) {
|
||||
|
||||
if (!(*itr).empty()) {
|
||||
int64_t throttle_max = control->core()->retrieve_throttle_value(*itr, false, up);
|
||||
if (!throttle_name.empty()) {
|
||||
int64_t throttle_max = control->core()->retrieve_throttle_value(throttle_name, false, up);
|
||||
|
||||
if (throttle_max > 0)
|
||||
firstc = print_buffer(firstc, lastc, "|%1.0f", (double)throttle_max / 1024.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add temp buffer (chop first char first) into main buffer if temp buffer isn't empty
|
||||
@@ -321,10 +320,10 @@ print_status_throttle_rate(char* first, char* last, bool up, const ui::ThrottleN
|
||||
char* firstc = throttle_str;
|
||||
char* lastc = throttle_str + 50 - 1;
|
||||
|
||||
for (ui::ThrottleNameList::const_iterator itr = throttle_names.begin(), laste = throttle_names.end(); itr != laste; itr++) {
|
||||
for (const auto& throttle_name : throttle_names) {
|
||||
|
||||
if (!(*itr).empty() && (up ? torrent::up_throttle_global()->is_throttled() : torrent::down_throttle_global()->is_throttled())) {
|
||||
int64_t throttle_rate_value = control->core()->retrieve_throttle_value(*itr, true, up);
|
||||
if (!throttle_name.empty() && (up ? torrent::up_throttle_global()->is_throttled() : torrent::down_throttle_global()->is_throttled())) {
|
||||
int64_t throttle_rate_value = control->core()->retrieve_throttle_value(throttle_name, true, up);
|
||||
|
||||
if (throttle_rate_value > -1) {
|
||||
double throttle_rate = (double)throttle_rate_value / 1024.0;
|
||||
@@ -333,7 +332,6 @@ print_status_throttle_rate(char* first, char* last, bool up, const ui::ThrottleN
|
||||
firstc = print_buffer(firstc, lastc, "|%3.1f", throttle_rate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add temp buffer into main buffer if temp buffer isn't empty
|
||||
|
||||
@@ -40,7 +40,7 @@ WindowDownloadTransferList::redraw() {
|
||||
m_canvas->print(0, y, "%5u [P: %u F: %u]", (*itr)->index(), (*itr)->priority(), (*itr)->failed());
|
||||
|
||||
// Handle window size.
|
||||
for (torrent::BlockList::const_iterator bItr = (*itr)->begin(), bLast = (*itr)->end(); bItr != bLast; ++bItr) {
|
||||
for (const auto& bItr : **itr) {
|
||||
if (m_canvas->get_x() >= m_canvas->width() - 1) {
|
||||
if (++y >= m_canvas->height())
|
||||
break;
|
||||
@@ -51,22 +51,22 @@ WindowDownloadTransferList::redraw() {
|
||||
char id;
|
||||
chtype attr = A_NORMAL;
|
||||
|
||||
if (bItr->is_finished()) {
|
||||
if (bItr.is_finished()) {
|
||||
attr = A_REVERSE;
|
||||
id = key_id(bItr->leader()->const_peer_info());
|
||||
id = key_id(bItr.leader()->const_peer_info());
|
||||
|
||||
} else if (bItr->is_transfering()) {
|
||||
} else if (bItr.is_transfering()) {
|
||||
attr = A_BOLD;
|
||||
id = key_id(bItr->leader()->const_peer_info());
|
||||
id = key_id(bItr.leader()->const_peer_info());
|
||||
|
||||
} else if (bItr->queued()->size() >= 1) {
|
||||
id = std::tolower(key_id(bItr->queued()->back()->const_peer_info()));
|
||||
} else if (bItr.queued()->size() >= 1) {
|
||||
id = std::tolower(key_id(bItr.queued()->back()->const_peer_info()));
|
||||
|
||||
} else {
|
||||
id = '.';
|
||||
}
|
||||
|
||||
if (bItr->size_all() > 1)
|
||||
if (bItr.size_all() > 1)
|
||||
attr |= A_UNDERLINE;
|
||||
|
||||
m_canvas->print_char(attr | id);
|
||||
|
||||
@@ -58,8 +58,8 @@ PathInput::pressed(int key) {
|
||||
return TextInput::pressed(key);
|
||||
|
||||
} else if (m_showNext) {
|
||||
for (signal_void::iterator itr = m_signal_show_next.begin(), last = m_signal_show_next.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
for (auto& itr : m_signal_show_next)
|
||||
itr();
|
||||
|
||||
} else {
|
||||
receive_do_complete();
|
||||
@@ -118,8 +118,8 @@ PathInput::receive_do_complete() {
|
||||
if (m_showNext) {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: show next page");
|
||||
|
||||
for (signal_itr_itr::iterator itr = m_signal_show_range.begin(), last = m_signal_show_range.end(); itr != last; itr++)
|
||||
(*itr)(r.first, r.second);
|
||||
for (auto& itr : m_signal_show_range)
|
||||
itr(r.first, r.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -86,11 +86,11 @@ void
|
||||
load_session_torrents() {
|
||||
utils::Directory entries = control->core()->download_store()->get_formated_entries();
|
||||
|
||||
for (utils::Directory::const_iterator first = entries.begin(), last = entries.end(); first != last; ++first) {
|
||||
for (const auto& entry : entries) {
|
||||
// We don't really support session torrents that are links. These
|
||||
// would be overwritten anyway on exit, and thus not really be
|
||||
// useful.
|
||||
if (!first->is_file())
|
||||
if (!entry.is_file())
|
||||
continue;
|
||||
|
||||
core::DownloadFactory* f = new core::DownloadFactory(control->core());
|
||||
@@ -99,7 +99,7 @@ load_session_torrents() {
|
||||
f->set_session(true);
|
||||
f->set_init_load(true);
|
||||
f->slot_finished([f](){ delete f; });
|
||||
f->load(entries.path() + first->s_name);
|
||||
f->load(entries.path() + entry.s_name);
|
||||
f->commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,10 @@ std::string
|
||||
OptionParser::create_optstring() {
|
||||
std::string s;
|
||||
|
||||
for (Container::iterator itr = m_container.begin(); itr != m_container.end(); ++itr) {
|
||||
s += itr->first;
|
||||
for (auto& itr : m_container) {
|
||||
s += itr.first;
|
||||
|
||||
if (itr->second.m_useOption)
|
||||
if (itr.second.m_useOption)
|
||||
s += ':';
|
||||
}
|
||||
|
||||
|
||||
@@ -268,8 +268,8 @@ object_storage::rlookup_clear(const std::string& cmd_key) {
|
||||
if (r_itr == m_rlookup.end())
|
||||
return;
|
||||
|
||||
for (rlookup_mapped_iterator first = r_itr->second.begin(), last = r_itr->second.end(); first != last; first++)
|
||||
(*first)->second.object.erase_key(cmd_key);
|
||||
for (auto& first : r_itr->second)
|
||||
first->second.object.erase_key(cmd_key);
|
||||
|
||||
r_itr->second.clear();
|
||||
}
|
||||
|
||||
+4
-4
@@ -455,8 +455,8 @@ print_object(char* first, char* last, const torrent::Object* src, int flags) {
|
||||
if (first != last)
|
||||
*first = '\0';
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
first = print_object(first, last, &*itr, flags);
|
||||
for (const auto& itr : src->as_list()) {
|
||||
first = print_object(first, last, &itr, flags);
|
||||
|
||||
// Don't expand tilde after the first element in the list.
|
||||
flags &= ~print_expand_tilde;
|
||||
@@ -497,8 +497,8 @@ print_object_std(std::string* dest, const torrent::Object* src, int flags) {
|
||||
return;
|
||||
}
|
||||
case torrent::Object::TYPE_LIST:
|
||||
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||
print_object_std(dest, &*itr, flags);
|
||||
for (const auto& itr : src->as_list()) {
|
||||
print_object_std(dest, &itr, flags);
|
||||
|
||||
// Don't expand tilde after the first element in the list.
|
||||
flags &= ~print_expand_tilde;
|
||||
|
||||
@@ -43,11 +43,11 @@ parse_command_execute(target_type target, torrent::Object* object) {
|
||||
if (object->is_list()) {
|
||||
// For now, until we can flag the lists we want executed and those
|
||||
// we can't, disable recursion completely.
|
||||
for (torrent::Object::list_iterator itr = object->as_list().begin(), last = object->as_list().end(); itr != last; itr++) {
|
||||
if (itr->is_list())
|
||||
for (auto& itr : object->as_list()) {
|
||||
if (itr.is_list())
|
||||
continue;
|
||||
|
||||
parse_command_execute(target, &*itr);
|
||||
parse_command_execute(target, &itr);
|
||||
}
|
||||
|
||||
} else if (object->is_dict_key()) {
|
||||
@@ -203,15 +203,15 @@ call_object(const torrent::Object& command, target_type target) {
|
||||
{
|
||||
torrent::Object result;
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = command.as_list().begin(), last = command.as_list().end(); itr != last; itr++)
|
||||
result = call_object(*itr, target);
|
||||
for (const auto& itr : command.as_list())
|
||||
result = call_object(itr, target);
|
||||
|
||||
return result;
|
||||
}
|
||||
case torrent::Object::TYPE_MAP:
|
||||
{
|
||||
for (torrent::Object::map_const_iterator itr = command.as_map().begin(), last = command.as_map().end(); itr != last; itr++)
|
||||
call_object(itr->second, target);
|
||||
for (const auto& itr : command.as_map())
|
||||
call_object(itr.second, target);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
+9
-12
@@ -295,8 +295,8 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
const std::string& str = object.as_string();
|
||||
char buffer[str.size() + 1];
|
||||
char* dst = buffer;
|
||||
for (std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr)
|
||||
*dst++ = ((*itr < 0x20 && *itr != '\r' && *itr != '\n' && *itr != '\t') || (*itr & 0x80)) ? '?' : *itr;
|
||||
for (char itr : str)
|
||||
*dst++ = ((itr < 0x20 && itr != '\r' && itr != '\n' && itr != '\t') || (itr & 0x80)) ? '?' : itr;
|
||||
*dst = 0;
|
||||
|
||||
result = xmlrpc_string_new(env, buffer);
|
||||
@@ -309,8 +309,8 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
{
|
||||
xmlrpc_value* result = xmlrpc_array_new(env);
|
||||
|
||||
for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, *itr);
|
||||
for (const auto& itr : object.as_list()) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, itr);
|
||||
xmlrpc_array_append_item(env, result, item);
|
||||
xmlrpc_DECREF(item);
|
||||
}
|
||||
@@ -322,9 +322,9 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
{
|
||||
xmlrpc_value* result = xmlrpc_struct_new(env);
|
||||
|
||||
for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, itr->second);
|
||||
xmlrpc_struct_set_value(env, result, itr->first.c_str(), item);
|
||||
for (const auto& itr : object.as_map()) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, itr.second);
|
||||
xmlrpc_struct_set_value(env, result, itr.first.c_str(), item);
|
||||
xmlrpc_DECREF(item);
|
||||
}
|
||||
|
||||
@@ -340,11 +340,8 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
||||
xmlrpc_DECREF(key_item);
|
||||
|
||||
if (object.as_dict_obj().is_list()) {
|
||||
for (torrent::Object::list_const_iterator
|
||||
itr = object.as_dict_obj().as_list().begin(),
|
||||
last = object.as_dict_obj().as_list().end();
|
||||
itr != last; itr++) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, *itr);
|
||||
for (const auto& itr : object.as_dict_obj().as_list()) {
|
||||
xmlrpc_value* item = object_to_xmlrpc(env, itr);
|
||||
xmlrpc_array_append_item(env, result, item);
|
||||
xmlrpc_DECREF(item);
|
||||
}
|
||||
|
||||
@@ -279,14 +279,13 @@ ElementFileList::receive_priority() {
|
||||
|
||||
void
|
||||
ElementFileList::receive_change_all() {
|
||||
if (m_window == NULL)
|
||||
if (m_window == nullptr)
|
||||
return;
|
||||
|
||||
torrent::FileList* fl = m_download->download()->file_list();
|
||||
auto priority = torrent::priority_enum((m_selected.file()->priority() + 2) % 3);
|
||||
|
||||
for (torrent::FileList::iterator itr = fl->begin(), last = fl->end(); itr != last; ++itr)
|
||||
(*itr)->set_priority(priority);
|
||||
for (const auto& file : *m_download->download()->file_list())
|
||||
file->set_priority(priority);
|
||||
|
||||
m_download->download()->update_priorities();
|
||||
update_itr();
|
||||
|
||||
+14
-15
@@ -349,20 +349,19 @@ Root::set_input_history_size(int size) {
|
||||
if (size < 1)
|
||||
throw torrent::input_error("Invalid input history size.");
|
||||
|
||||
for (InputHistory::iterator itr = m_input_history.begin(), last = m_input_history.end(); itr != last; itr++) {
|
||||
for (auto& [entry, category] : m_input_history) {
|
||||
// Reserve the latest input history entries if new size is smaller than original.
|
||||
if (size < m_input_history_length) {
|
||||
int pointer_offset = m_input_history_length - size;
|
||||
InputHistoryPointers::iterator pitr = m_input_history_pointers.find(itr->first);
|
||||
InputHistoryCategory input_history_category_tmp = itr->second;
|
||||
InputHistoryPointers::iterator pitr = m_input_history_pointers.find(entry);
|
||||
|
||||
for (int i=0; i != size; i++)
|
||||
itr->second.at(i) = input_history_category_tmp.at((pitr->second + pointer_offset + i) % m_input_history_length);
|
||||
category.at(i) = category.at((pitr->second + pointer_offset + i) % m_input_history_length);
|
||||
|
||||
m_input_history_pointers[pitr->first] = 0;
|
||||
}
|
||||
|
||||
itr->second.resize(size);
|
||||
category.resize(size);
|
||||
}
|
||||
|
||||
m_input_history_length = size;
|
||||
@@ -412,20 +411,20 @@ Root::load_input_history() {
|
||||
lt_log_print(torrent::LOG_DEBUG, "input history file read (path:%s)", history_filename.c_str());
|
||||
}
|
||||
|
||||
for (InputHistory::const_iterator itr = input_history_tmp.begin(), last = input_history_tmp.end(); itr != last; itr++) {
|
||||
int input_history_tmp_category_length = itr->second.size();
|
||||
InputHistory::iterator hitr = m_input_history.find(itr->first);
|
||||
InputHistoryPointers::iterator pitr = m_input_history_pointers.find(itr->first);
|
||||
for (const auto& [entry, category] : input_history_tmp) {
|
||||
int input_history_tmp_category_length = category.size();
|
||||
InputHistory::iterator hitr = m_input_history.find(entry);
|
||||
InputHistoryPointers::iterator pitr = m_input_history_pointers.find(entry);
|
||||
|
||||
if (m_input_history_length < input_history_tmp_category_length) {
|
||||
int pointer_offset = input_history_tmp_category_length - m_input_history_length;
|
||||
|
||||
for (int i=0; i != m_input_history_length; i++)
|
||||
hitr->second.at(i) = itr->second.at((pointer_offset + i) % input_history_tmp_category_length);
|
||||
hitr->second.at(i) = category.at((pointer_offset + i) % input_history_tmp_category_length);
|
||||
|
||||
pitr->second = 0;
|
||||
} else {
|
||||
hitr->second = itr->second;
|
||||
hitr->second = category;
|
||||
hitr->second.resize(m_input_history_length);
|
||||
|
||||
pitr->second = input_history_tmp_category_length % m_input_history_length;
|
||||
@@ -450,12 +449,12 @@ Root::save_input_history() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (InputHistory::const_iterator itr = m_input_history.begin(), last = m_input_history.end(); itr != last; itr++) {
|
||||
InputHistoryPointers::const_iterator pitr = m_input_history_pointers.find(itr->first);
|
||||
for (const auto& [entry, category] : m_input_history) {
|
||||
InputHistoryPointers::const_iterator pitr = m_input_history_pointers.find(entry);
|
||||
|
||||
for (int i=0; i != m_input_history_length; i++)
|
||||
if (!itr->second.at((pitr->second + i) % m_input_history_length).empty())
|
||||
history_file << itr->first << "|" + itr->second.at((pitr->second + i) % m_input_history_length) + "\n";
|
||||
if (!category.at((pitr->second + i) % m_input_history_length).empty())
|
||||
history_file << entry << "|" + category.at((pitr->second + i) % m_input_history_length) + "\n";
|
||||
}
|
||||
|
||||
if (!history_file.good()) {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#define RTORRENT_UTILS_LIST_FOCUS_H
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
namespace utils {
|
||||
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
|
||||
typedef typename base_type::value_type value_type;
|
||||
|
||||
ListFocus(base_type* b = NULL) : m_base(b) { if (b) m_focus = b->end(); }
|
||||
ListFocus(base_type* b = nullptr) : m_base(b) { if (b) m_focus = b->end(); }
|
||||
|
||||
// Convinience functions, would have added more through using, but
|
||||
// can't.
|
||||
@@ -149,8 +150,8 @@ ListFocus<Base>::remove(const value_type& v) {
|
||||
template <typename Base>
|
||||
void
|
||||
ListFocus<Base>::emit_changed() {
|
||||
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
for (const auto& itr : m_signal_changed)
|
||||
itr();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user