From 7124efe64dad04c688a14e7f2189f04f97721415 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Fri, 16 Jun 2017 18:31:24 +0100 Subject: [PATCH] Refactoring: don't pass list via pointer. --- src/load_service.cc | 11 ++++++----- src/service.cc | 4 ++-- src/service.h | 24 ++++++++++++------------ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/load_service.cc b/src/load_service.cc index 496341d..8ebab76 100644 --- a/src/load_service.cc +++ b/src/load_service.cc @@ -585,14 +585,14 @@ service_record * dirload_service_set::load_service(const char * name) delete rval; if (service_type == service_type::PROCESS) { auto rvalps = new process_service(this, string(name), std::move(command), - command_offsets, &depends_on, &depends_soft); + command_offsets, std::move(depends_on), depends_soft); rvalps->set_restart_interval(restart_interval, max_restarts); rvalps->set_restart_delay(restart_delay); rval = rvalps; } else if (service_type == service_type::BGPROCESS) { auto rvalps = new bgproc_service(this, string(name), std::move(command), - command_offsets, &depends_on, &depends_soft); + command_offsets, std::move(depends_on), depends_soft); rvalps->set_pid_file(std::move(pid_file)); rvalps->set_restart_interval(restart_interval, max_restarts); rvalps->set_restart_delay(restart_delay); @@ -600,12 +600,13 @@ service_record * dirload_service_set::load_service(const char * name) } else if (service_type == service_type::SCRIPTED) { rval = new scripted_service(this, string(name), std::move(command), - command_offsets, &depends_on, &depends_soft); + command_offsets, std::move(depends_on), depends_soft); rval->setStopCommand(stop_command, stop_command_offsets); } else { - rval = new service_record(this, string(name), service_type, std::move(command), command_offsets, - &depends_on, &depends_soft); + rval = new service_record(this, string(name), service_type, + std::move(command), command_offsets, + std::move(depends_on), depends_soft); } rval->setLogfile(logfile); rval->setAutoRestart(auto_restart); diff --git a/src/service.cc b/src/service.cc index 21e8af4..90d5b2e 100644 --- a/src/service.cc +++ b/src/service.cc @@ -1212,9 +1212,9 @@ void service_set::service_inactive(service_record *sr) noexcept base_process_service::base_process_service(service_set *sset, string name, service_type service_type_p, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) : service_record(sset, name, service_type_p, std::move(command), command_offsets, - pdepends_on, pdepends_soft), child_listener(this), child_status_listener(this) + std::move(pdepends_on), pdepends_soft), child_listener(this), child_status_listener(this) { restart_interval_count = 0; restart_interval_time = {0, 0}; diff --git a/src/service.h b/src/service.h index 1828d52..0ee545d 100644 --- a/src/service.h +++ b/src/service.h @@ -430,13 +430,13 @@ class service_record } service_record(service_set *set, string name, service_type record_type_p, - sr_list * pdepends_on, sr_list * pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) : service_record(set, name) { services = set; service_name = name; this->record_type = record_type_p; - this->depends_on = std::move(*pdepends_on); + this->depends_on = std::move(pdepends_on); for (sr_iter i = depends_on.begin(); i != depends_on.end(); ++i) { (*i)->dependents.push_back(this); @@ -444,7 +444,7 @@ class service_record // Soft dependencies auto b_iter = soft_deps.end(); - for (sr_iter i = pdepends_soft->begin(); i != pdepends_soft->end(); ++i) { + for (auto i = pdepends_soft.begin(); i != pdepends_soft.end(); ++i) { b_iter = soft_deps.emplace(b_iter, this, *i); (*i)->soft_dpts.push_back(&(*b_iter)); ++b_iter; @@ -452,8 +452,8 @@ class service_record } service_record(service_set *set, string name, service_type record_type_p, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft) - : service_record(set, name, record_type_p, pdepends_on, pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) + : service_record(set, name, record_type_p, std::move(pdepends_on), pdepends_soft) { program_name = std::move(command); exec_arg_parts = separate_args(program_name, command_offsets); @@ -645,7 +645,7 @@ class base_process_service : public service_record public: base_process_service(service_set *sset, string name, service_type record_type_p, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft); + sr_list &&pdepends_on, const sr_list &pdepends_soft); ~base_process_service() noexcept { @@ -672,9 +672,9 @@ class process_service : public base_process_service public: process_service(service_set *sset, string name, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) : base_process_service(sset, name, service_type::PROCESS, std::move(command), command_offsets, - pdepends_on, pdepends_soft) + std::move(pdepends_on), pdepends_soft) { } @@ -696,9 +696,9 @@ class bgproc_service : public base_process_service public: bgproc_service(service_set *sset, string name, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) : base_process_service(sset, name, service_type::BGPROCESS, std::move(command), command_offsets, - pdepends_on, pdepends_soft) + std::move(pdepends_on), pdepends_soft) { doing_recovery = false; } @@ -716,9 +716,9 @@ class scripted_service : public base_process_service public: scripted_service(service_set *sset, string name, string &&command, std::list> &command_offsets, - sr_list * pdepends_on, sr_list * pdepends_soft) + sr_list &&pdepends_on, const sr_list &pdepends_soft) : base_process_service(sset, name, service_type::SCRIPTED, std::move(command), command_offsets, - pdepends_on, pdepends_soft) + std::move(pdepends_on), pdepends_soft) { } -- 2.25.1