From: Arnaud Giersch Date: Mon, 11 Feb 2019 20:09:18 +0000 (+0100) Subject: Whenever possible, use std::move() for parameters (mostly std::string). X-Git-Tag: v3_22~348 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c1b3e440de2150420b08c0bc55a125a0c9eb86bc Whenever possible, use std::move() for parameters (mostly std::string). --- diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index 675d959f66..db16dd9525 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -34,7 +34,12 @@ class ThrowPoint { public: ThrowPoint() = default; explicit ThrowPoint(const char* file, int line, const char* function, Backtrace bt, std::string actor_name, int pid) - : file_(file), line_(line), function_(function), backtrace_(std::move(bt)), procname_(actor_name), pid_(pid) + : file_(file) + , line_(line) + , function_(function) + , backtrace_(std::move(bt)) + , procname_(std::move(actor_name)) + , pid_(pid) { } @@ -56,7 +61,7 @@ public: class Exception : public std::runtime_error { public: Exception(simgrid::xbt::ThrowPoint throwpoint, std::string message) - : std::runtime_error(message), throwpoint_(throwpoint) + : std::runtime_error(std::move(message)), throwpoint_(std::move(throwpoint)) { } @@ -91,8 +96,11 @@ public: * @param throwpoint Throw point (use XBT_THROW_POINT) * @param message Exception message */ - xbt_ex(simgrid::xbt::ThrowPoint throwpoint, std::string message) : simgrid::Exception(throwpoint, message) {} - + xbt_ex(simgrid::xbt::ThrowPoint throwpoint, std::string message) + : simgrid::Exception(std::move(throwpoint), std::move(message)) + { + } + xbt_ex(const xbt_ex&) = default; ~xbt_ex(); // DO NOT define it here -- see ex.cpp for a rationale @@ -109,7 +117,8 @@ namespace simgrid { /** Exception raised when a timeout elapsed */ class TimeoutError : public xbt_ex { public: - TimeoutError(simgrid::xbt::ThrowPoint throwpoint, std::string message) : xbt_ex(throwpoint, message) + TimeoutError(simgrid::xbt::ThrowPoint throwpoint, std::string message) + : xbt_ex(std::move(throwpoint), std::move(message)) { category = timeout_error; } @@ -118,7 +127,8 @@ public: /** Exception raised when a host fails */ class HostFailureException : public xbt_ex { public: - HostFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) : xbt_ex(throwpoint, message) + HostFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) + : xbt_ex(std::move(throwpoint), std::move(message)) { category = host_error; } @@ -127,7 +137,8 @@ public: /** Exception raised when a communication fails because of the network */ class NetworkFailureException : public xbt_ex { public: - NetworkFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) : xbt_ex(throwpoint, message) + NetworkFailureException(simgrid::xbt::ThrowPoint throwpoint, std::string message) + : xbt_ex(std::move(throwpoint), std::move(message)) { category = network_error; } diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 2e13349e84..51d8af9aff 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -181,7 +181,7 @@ public: /** @brief Get the tracing category associated to the current action */ std::string get_category() const { return category_; } /** @brief Set the tracing category of the current Action */ - void set_category(std::string category) { category_ = category; } + void set_category(std::string category) { category_ = std::move(category); } /** @brief Get the priority of the current Action */ double get_priority() const { return sharing_priority_; }; diff --git a/include/simgrid/kernel/routing/DragonflyZone.hpp b/include/simgrid/kernel/routing/DragonflyZone.hpp index 4b35093cf8..aaec77a7f2 100644 --- a/include/simgrid/kernel/routing/DragonflyZone.hpp +++ b/include/simgrid/kernel/routing/DragonflyZone.hpp @@ -73,7 +73,7 @@ public: private: void generate_routers(); void generate_links(); - void create_link(const std::string& id, int numlinks, resource::LinkImpl** linkup, resource::LinkImpl** linkdown); + void create_link(std::string id, int numlinks, resource::LinkImpl** linkup, resource::LinkImpl** linkdown); simgrid::s4u::Link::SharingPolicy sharing_policy_; double bw_ = 0; diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 3b1cffa0cf..b6798d3576 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -176,7 +176,7 @@ public: */ template static ActorPtr create(std::string name, s4u::Host* host, F code) { - return create(name, host, std::function(std::move(code))); + return create(std::move(name), host, std::function(std::move(code))); } /** Create an actor using a callable thing and its arguments. @@ -187,7 +187,7 @@ public: typename = typename std::result_of::type> static ActorPtr create(std::string name, s4u::Host* host, F code, Args... args) { - return create(name, host, std::bind(std::move(code), std::move(args)...)); + return create(std::move(name), host, std::bind(std::move(code), std::move(args)...)); } // Create actor from function name: diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index 46f5d86fb2..045b936ba8 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -175,7 +175,7 @@ protected: T args; public: - explicit ReplayAction(std::string name) : name(name), my_proc_id(simgrid::s4u::this_actor::get_pid()) {} + explicit ReplayAction(std::string name) : name(std::move(name)), my_proc_id(simgrid::s4u::this_actor::get_pid()) {} virtual ~ReplayAction() = default; void execute(simgrid::xbt::ReplayAction& action) @@ -207,7 +207,9 @@ private: RequestStorage& req_storage; public: - explicit SendAction(std::string name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + explicit SendAction(std::string name, RequestStorage& storage) : ReplayAction(std::move(name)), req_storage(storage) + { + } void kernel(simgrid::xbt::ReplayAction& action) override; }; @@ -216,7 +218,9 @@ private: RequestStorage& req_storage; public: - explicit RecvAction(std::string name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + explicit RecvAction(std::string name, RequestStorage& storage) : ReplayAction(std::move(name)), req_storage(storage) + { + } void kernel(simgrid::xbt::ReplayAction& action) override; }; @@ -288,13 +292,13 @@ public: class GatherAction : public ReplayAction { public: - explicit GatherAction(std::string name) : ReplayAction(name) {} + explicit GatherAction(std::string name) : ReplayAction(std::move(name)) {} void kernel(simgrid::xbt::ReplayAction& action) override; }; class GatherVAction : public ReplayAction { public: - explicit GatherVAction(std::string name) : ReplayAction(name) {} + explicit GatherVAction(std::string name) : ReplayAction(std::move(name)) {} void kernel(simgrid::xbt::ReplayAction& action) override; }; diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index edf7c37dba..7bc177c4eb 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -33,10 +33,10 @@ container_t Container::get_root() } NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father) - : Container::Container(name, "", father) + : Container::Container(std::move(name), "", father) { - netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name); - xbt_assert(netpoint_, "Element '%s' not found", name.c_str()); + netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()); + xbt_assert(netpoint_, "Element '%s' not found", get_cname()); if (father_) { std::string type_name = std::string("L") + std::to_string(level); type_ = father_->type_->by_name_or_create(type_name); @@ -48,12 +48,13 @@ NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZone } } -RouterContainer::RouterContainer(std::string name, Container* father) : Container::Container(name, "ROUTER", father) +RouterContainer::RouterContainer(std::string name, Container* father) + : Container::Container(std::move(name), "ROUTER", father) { xbt_assert(father, "Only the Root container has no father"); - netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name); - xbt_assert(netpoint_, "Element '%s' not found", name.c_str()); + netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()); + xbt_assert(netpoint_, "Element '%s' not found", get_cname()); trivaNodeTypes.insert(type_->get_name()); } @@ -69,7 +70,8 @@ HostContainer::HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father) trivaNodeTypes.insert(type_->get_name()); } -Container::Container(std::string name, std::string type_name, Container* father) : name_(name), father_(father) +Container::Container(std::string name, std::string type_name, Container* father) + : name_(std::move(name)), father_(father) { static long long int container_id = 0; id_ = container_id; // id (or alias) of the container @@ -117,7 +119,7 @@ Container::~Container() void Container::create_child(std::string name, std::string type_name) { - new Container(name, type_name, this); + new Container(std::move(name), std::move(type_name), this); } Container* Container::by_name_or_null(std::string name) diff --git a/src/instr/instr_paje_events.hpp b/src/instr/instr_paje_events.hpp index 6760f77871..2590273400 100644 --- a/src/instr/instr_paje_events.hpp +++ b/src/instr/instr_paje_events.hpp @@ -88,7 +88,7 @@ public: std::string key, int size) : PajeEvent(container, type, SIMIX_get_clock(), event_type) , endpoint_(sourceContainer) - , value_(value) + , value_(std::move(value)) , key_(key) , size_(size) { diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 5b3987431c..f2481a4c9c 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -16,13 +16,13 @@ namespace simgrid { namespace instr { Type::Type(std::string name, std::string alias, std::string color, Type* father) - : id_(instr_new_paje_id()), name_(name), color_(color), father_(father) + : id_(instr_new_paje_id()), name_(std::move(name)), color_(std::move(color)), father_(father) { - if (name.empty() || alias.empty()) + if (name_.empty() || alias.empty()) THROWF(tracing_error, 0, "can't create a new type with no name or alias"); if (father != nullptr){ - father->children_.insert({alias, this}); + father->children_.insert({std::move(alias), this}); XBT_DEBUG("new type %s, child of %s", name_.c_str(), father->get_cname()); } if (trace_format == simgrid::instr::TraceFormat::Paje) { @@ -48,13 +48,13 @@ ContainerType::ContainerType(std::string name, Type* father) : Type(name, name, log_definition(PAJE_DefineContainerType); } -EventType::EventType(std::string name, Type* father) : ValueType(name, father) +EventType::EventType(std::string name, Type* father) : ValueType(std::move(name), father) { XBT_DEBUG("EventType %s(%lld), child of %s(%lld)", get_cname(), get_id(), father->get_cname(), father->get_id()); log_definition(PAJE_DefineEventType); } -StateType::StateType(std::string name, Type* father) : ValueType(name, father) +StateType::StateType(std::string name, Type* father) : ValueType(std::move(name), father) { XBT_DEBUG("StateType %s(%lld), child of %s(%lld)", get_cname(), get_id(), father->get_cname(), father->get_id()); log_definition(PAJE_DefineStateType); @@ -90,7 +90,8 @@ void StateType::pop_event(TIData* extra) events_.push_back(new StateEvent(issuer_, this, PAJE_PopState, nullptr, extra)); } -VariableType::VariableType(std::string name, std::string color, Type* father) : Type(name, name, color, father) +VariableType::VariableType(std::string name, std::string color, Type* father) + : Type(name, name, std::move(color), father) { XBT_DEBUG("VariableType %s(%lld), child of %s(%lld)", get_cname(), get_id(), father->get_cname(), father->get_id()); log_definition(PAJE_DefineVariableType); @@ -136,22 +137,23 @@ void VariableType::sub_event(double timestamp, double value) events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SubVariable, value)); } -LinkType::LinkType(std::string name, std::string alias, Type* father) : ValueType(name, alias, father) +LinkType::LinkType(std::string name, std::string alias, Type* father) + : ValueType(std::move(name), std::move(alias), father) { } void LinkType::start_event(Container* startContainer, std::string value, std::string key) { - start_event(startContainer, value, key, -1); + start_event(startContainer, value, std::move(key), -1); } void LinkType::start_event(Container* startContainer, std::string value, std::string key, int size) { - new LinkEvent(issuer_, this, PAJE_StartLink, startContainer, value, key, size); + new LinkEvent(issuer_, this, PAJE_StartLink, startContainer, value, std::move(key), size); } void LinkType::end_event(Container* endContainer, std::string value, std::string key) { - new LinkEvent(issuer_, this, PAJE_EndLink, endContainer, value, key, -1); + new LinkEvent(issuer_, this, PAJE_EndLink, endContainer, value, std::move(key), -1); } void Type::log_definition(e_event_type event_type) @@ -206,7 +208,7 @@ void ValueType::add_entity_value(std::string name, std::string color) auto it = values_.find(name); if (it == values_.end()) { - EntityValue* new_val = new EntityValue(name, color, this); + EntityValue* new_val = new EntityValue(name, std::move(color), this); values_.insert({name, new_val}); XBT_DEBUG("new value %s, child of %s", name.c_str(), get_cname()); new_val->print(); @@ -225,8 +227,9 @@ EntityValue* ValueType::get_entity_value(std::string name) VariableType* Type::by_name_or_create(std::string name, std::string color) { auto cont = children_.find(name); - std::string mycolor = color.empty() ? "1 1 1" : color; - return cont == children_.end() ? new VariableType(name, mycolor, this) : static_cast(cont->second); + std::string mycolor = color.empty() ? "1 1 1" : std::move(color); + return cont == children_.end() ? new VariableType(name, std::move(mycolor), this) + : static_cast(cont->second); } LinkType* Type::by_name_or_create(std::string name, Type* source, Type* dest) diff --git a/src/instr/instr_paje_types.hpp b/src/instr/instr_paje_types.hpp index 443032bee2..80c7a8b2a8 100644 --- a/src/instr/instr_paje_types.hpp +++ b/src/instr/instr_paje_types.hpp @@ -71,7 +71,7 @@ public: class ValueType : public Type { public: std::map values_; - ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){}; + ValueType(std::string name, std::string alias, Type* father) : Type(std::move(name), std::move(alias), "", father){}; ValueType(std::string name, Type* father) : Type(name, name, "", father){}; virtual ~ValueType(); void add_entity_value(std::string name, std::string color); diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index 77b643d7ec..4b584d6994 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -13,7 +13,7 @@ namespace simgrid { namespace instr { EntityValue::EntityValue(std::string name, std::string color, Type* father) - : id_(instr_new_paje_id()), name_(name), color_(color), father_(father){}; + : id_(instr_new_paje_id()), name_(std::move(name)), color_(std::move(color)), father_(father){}; void EntityValue::print() { diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index c61dc20912..deed561a3c 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -59,39 +59,39 @@ public: std::string recv_type = ""; // NoOpTI: init, finalize, test, wait, barrier - explicit TIData(std::string name) : name_(name){}; + explicit TIData(std::string name) : name_(std::move(name)){}; // CPuTI: compute, sleep (+ waitAny and waitall out of laziness) - explicit TIData(std::string name, double amount) : name_(name), amount_(amount){}; + explicit TIData(std::string name, double amount) : name_(std::move(name)), amount_(amount){}; // Pt2PtTI: send, isend, sssend, issend, recv, irecv explicit TIData(std::string name, int endpoint, int size, std::string datatype) - : name_(name), endpoint(endpoint), send_size(size), send_type(datatype){}; + : name_(std::move(name)), endpoint(endpoint), send_size(size), send_type(std::move(datatype)){}; // CollTI: bcast, reduce, allreduce, gather, scatter, allgather, alltoall explicit TIData(std::string name, int root, double amount, int send_size, int recv_size, std::string send_type, std::string recv_type) - : name_(name) + : name_(std::move(name)) , amount_(amount) , endpoint(root) , send_size(send_size) , recv_size(recv_size) - , send_type(send_type) - , recv_type(recv_type){}; + , send_type(std::move(send_type)) + , recv_type(std::move(recv_type)){}; // VarCollTI: gatherv, scatterv, allgatherv, alltoallv (+ reducescatter out of laziness) explicit TIData(std::string name, int root, int send_size, std::vector* sendcounts, int recv_size, std::vector* recvcounts, std::string send_type, std::string recv_type) - : TIData(name, root, send_size, std::shared_ptr>(sendcounts), recv_size, - std::shared_ptr>(recvcounts), send_type, recv_type){}; + : TIData(std::move(name), root, send_size, std::shared_ptr>(sendcounts), recv_size, + std::shared_ptr>(recvcounts), std::move(send_type), std::move(recv_type)){}; explicit TIData(std::string name, int root, int send_size, std::shared_ptr> sendcounts, int recv_size, std::shared_ptr> recvcounts, std::string send_type, std::string recv_type) - : name_(name) + : name_(std::move(name)) , endpoint(root) , send_size(send_size) , sendcounts(sendcounts) , recv_size(recv_size) , recvcounts(recvcounts) - , send_type(send_type) - , recv_type(recv_type){}; + , send_type(std::move(send_type)) + , recv_type(std::move(recv_type)){}; virtual ~TIData() {} @@ -103,14 +103,14 @@ public: class NoOpTIData : public TIData { public: - explicit NoOpTIData(std::string name) : TIData(name){}; + explicit NoOpTIData(std::string name) : TIData(std::move(name)){}; std::string print() override { return getName(); } std::string display_size() override { return "NA"; } }; class CpuTIData : public TIData { public: - explicit CpuTIData(std::string name, double amount) : TIData(name, amount){}; + explicit CpuTIData(std::string name, double amount) : TIData(std::move(name), amount){}; std::string print() override { std::stringstream stream; @@ -124,10 +124,10 @@ class Pt2PtTIData : public TIData { int tag; public: explicit Pt2PtTIData(std::string name, int endpoint, int size, int tag, std::string datatype) - : TIData(name, endpoint, size, datatype), tag(tag) {}; + : TIData(std::move(name), endpoint, size, std::move(datatype)), tag(tag){}; explicit Pt2PtTIData(std::string name, int endpoint, int size, std::string datatype) - : TIData(name, endpoint, size, datatype), tag(0) {}; + : TIData(std::move(name), endpoint, size, std::move(datatype)), tag(0){}; std::string print() override { std::stringstream stream; @@ -142,7 +142,7 @@ class CollTIData : public TIData { public: explicit CollTIData(std::string name, int root, double amount, int send_size, int recv_size, std::string send_type, std::string recv_type) - : TIData(name, root, amount, send_size, recv_size, send_type, recv_type){}; + : TIData(std::move(name), root, amount, send_size, recv_size, std::move(send_type), std::move(recv_type)){}; std::string print() override { std::stringstream stream; @@ -164,12 +164,14 @@ class VarCollTIData : public TIData { public: explicit VarCollTIData(std::string name, int root, int send_size, std::vector* sendcounts, int recv_size, std::vector* recvcounts, std::string send_type, std::string recv_type) - : TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){}; + : TIData(std::move(name), root, send_size, sendcounts, recv_size, recvcounts, std::move(send_type), + std::move(recv_type)){}; explicit VarCollTIData(std::string name, int root, int send_size, std::shared_ptr> sendcounts, int recv_size, std::shared_ptr> recvcounts, std::string send_type, std::string recv_type) - : TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){}; + : TIData(std::move(name), root, send_size, sendcounts, recv_size, recvcounts, std::move(send_type), + std::move(recv_type)){}; std::string print() override { diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index 96db16e52c..55c22f79e0 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -13,7 +13,7 @@ namespace simgrid{ namespace jedule{ Event::Event(std::string name, double start_time, double end_time, std::string type) - : name_(name), start_time_(start_time), end_time_(end_time), type_(type) + : name_(std::move(name)), start_time_(start_time), end_time_(end_time), type_(std::move(type)) { this->resource_subsets_ = new std::vector(); } diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index e331627786..ad4e515f8c 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -24,8 +24,7 @@ Subset::Subset(int start_idx, int end_idx, Container* parent) nres=end_idx-start_idx+1; } - -Container::Container(std::string name): name(name) +Container::Container(std::string name) : name(std::move(name)) { container_name2container.insert({this->name, this}); } diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index a2cdff3885..1cb313a845 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -32,7 +32,7 @@ void ActivityImpl::resume() void ActivityImpl::set_category(std::string category) { if (surf_action_) - surf_action_->set_category(category); + surf_action_->set_category(std::move(category)); } // boost::intrusive_ptr support: diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index ec860fcf7f..70f17cebfa 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -23,7 +23,7 @@ namespace activity { class XBT_PUBLIC ActivityImpl { public: ActivityImpl() = default; - explicit ActivityImpl(std::string name) : name_(name) {} + explicit ActivityImpl(std::string name) : name_(std::move(name)) {} virtual ~ActivityImpl() = default; e_smx_state_t state_ = SIMIX_WAITING; /* State of the activity */ std::string name_; /* Activity name if any */ diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index cac429ac5f..fbfe28c475 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -19,10 +19,10 @@ namespace kernel { namespace activity { ExecImpl::ExecImpl(std::string name, std::string tracing_category, resource::Action* timeout_detector, s4u::Host* host) - : ActivityImpl(name), host_(host), timeout_detector_(timeout_detector) + : ActivityImpl(std::move(name)), host_(host), timeout_detector_(timeout_detector) { this->state_ = SIMIX_RUNNING; - this->set_category(tracing_category); + this->set_category(std::move(tracing_category)); if (timeout_detector != nullptr) timeout_detector_->set_data(this); diff --git a/src/kernel/activity/IoImpl.cpp b/src/kernel/activity/IoImpl.cpp index 2d21d2793c..7f8d60bd95 100644 --- a/src/kernel/activity/IoImpl.cpp +++ b/src/kernel/activity/IoImpl.cpp @@ -13,7 +13,7 @@ namespace simgrid { namespace kernel { namespace activity { -IoImpl::IoImpl(std::string name, surf::StorageImpl* storage) : ActivityImpl(name), storage_(storage) +IoImpl::IoImpl(std::string name, surf::StorageImpl* storage) : ActivityImpl(std::move(name)), storage_(storage) { this->state_ = SIMIX_RUNNING; diff --git a/src/kernel/activity/MailboxImpl.hpp b/src/kernel/activity/MailboxImpl.hpp index 14c7d91064..232c4199f9 100644 --- a/src/kernel/activity/MailboxImpl.hpp +++ b/src/kernel/activity/MailboxImpl.hpp @@ -26,7 +26,7 @@ class MailboxImpl { friend mc::CommunicationDeterminismChecker; explicit MailboxImpl(std::string name) - : piface_(this), name_(name), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE) + : piface_(this), name_(std::move(name)), comm_queue_(MAX_MAILBOX_SIZE), done_comm_queue_(MAX_MAILBOX_SIZE) { } diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index ea7267b456..2f3d067f70 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -18,7 +18,7 @@ namespace simgrid { namespace kernel { namespace routing { ClusterZone::ClusterZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : NetZoneImpl(father, name, netmodel) + : NetZoneImpl(father, std::move(name), netmodel) { } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 02cf5c2331..a63574b958 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -27,7 +27,7 @@ public: }; DijkstraZone::DijkstraZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel, bool cached) - : RoutedZone(father, name, netmodel), cached_(cached) + : RoutedZone(father, std::move(name), netmodel), cached_(cached) { } diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index e94fca526b..603c6052a1 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -19,7 +19,7 @@ namespace kernel { namespace routing { DragonflyZone::DragonflyZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : ClusterZone(father, name, netmodel) + : ClusterZone(father, std::move(name), netmodel) { } @@ -160,7 +160,7 @@ void DragonflyZone::generate_routers() } } -void DragonflyZone::create_link(const std::string& id, int numlinks, resource::LinkImpl** linkup, +void DragonflyZone::create_link(std::string id, int numlinks, resource::LinkImpl** linkup, resource::LinkImpl** linkdown) { *linkup = nullptr; @@ -169,9 +169,9 @@ void DragonflyZone::create_link(const std::string& id, int numlinks, resource::L linkTemplate.bandwidth = this->bw_ * numlinks; linkTemplate.latency = this->lat_; linkTemplate.policy = this->sharing_policy_; - linkTemplate.id = id; + linkTemplate.id = std::move(id); sg_platf_new_link(&linkTemplate); - XBT_DEBUG("Generating link %s", id.c_str()); + XBT_DEBUG("Generating link %s", linkTemplate.id.c_str()); resource::LinkImpl* link; if (this->sharing_policy_ == s4u::Link::SharingPolicy::SPLITDUPLEX) { *linkup = s4u::Link::by_name(linkTemplate.id + "_UP")->get_impl(); // check link? diff --git a/src/kernel/routing/EmptyZone.cpp b/src/kernel/routing/EmptyZone.cpp index c07eb067fa..bd04471a71 100644 --- a/src/kernel/routing/EmptyZone.cpp +++ b/src/kernel/routing/EmptyZone.cpp @@ -16,7 +16,7 @@ namespace kernel { namespace routing { EmptyZone::EmptyZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : NetZoneImpl(father, name, netmodel) + : NetZoneImpl(father, std::move(name), netmodel) { } diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index eb9758b622..b6974dc22e 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -23,7 +23,7 @@ namespace kernel { namespace routing { FatTreeZone::FatTreeZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : ClusterZone(father, name, netmodel) + : ClusterZone(father, std::move(name), netmodel) { XBT_DEBUG("Creating a new fat tree."); } diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index ca4c2def76..c3d32b32ae 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -23,7 +23,7 @@ namespace kernel { namespace routing { FloydZone::FloydZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : RoutedZone(father, name, netmodel) + : RoutedZone(father, std::move(name), netmodel) { predecessor_table_ = nullptr; cost_table_ = nullptr; diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index b7037025df..f95f6e72bc 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -17,7 +17,7 @@ namespace simgrid { namespace kernel { namespace routing { FullZone::FullZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : RoutedZone(father, name, netmodel) + : RoutedZone(father, std::move(name), netmodel) { } diff --git a/src/kernel/routing/NetPoint.cpp b/src/kernel/routing/NetPoint.cpp index 2945ccf2eb..87409f62c7 100644 --- a/src/kernel/routing/NetPoint.cpp +++ b/src/kernel/routing/NetPoint.cpp @@ -16,7 +16,7 @@ namespace routing { simgrid::xbt::signal NetPoint::on_creation; NetPoint::NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* netzone_p) - : name_(name), component_type_(componentType), englobing_zone_(netzone_p) + : name_(std::move(name)), component_type_(componentType), englobing_zone_(netzone_p) { if (netzone_p != nullptr) id_ = netzone_p->add_component(this); diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index e727cac336..f61f9dfa50 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -27,13 +27,13 @@ public: }; NetZoneImpl::NetZoneImpl(NetZoneImpl* father, std::string name, resource::NetworkModel* network_model) - : network_model_(network_model), piface_(this), father_(father), name_(name) + : network_model_(network_model), piface_(this), father_(father), name_(std::move(name)) { - xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name.c_str()), - "Refusing to create a second NetZone called '%s'.", name.c_str()); + xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name_.c_str()), + "Refusing to create a second NetZone called '%s'.", name_.c_str()); - netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, father); - XBT_DEBUG("NetZone '%s' created with the id '%u'", name.c_str(), netpoint_->id()); + netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father); + XBT_DEBUG("NetZone '%s' created with the id '%u'", name_.c_str(), netpoint_->id()); } NetZoneImpl::~NetZoneImpl() diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index de14a37f6f..89685b1119 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -60,7 +60,7 @@ namespace kernel { namespace routing { RoutedZone::RoutedZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : NetZoneImpl(father, name, netmodel) + : NetZoneImpl(father, std::move(name), netmodel) { } diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index 7aeceb60b1..ddecf30cea 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -30,7 +30,7 @@ namespace simgrid { namespace kernel { namespace routing { TorusZone::TorusZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : ClusterZone(father, name, netmodel) + : ClusterZone(father, std::move(name), netmodel) { } diff --git a/src/kernel/routing/VivaldiZone.cpp b/src/kernel/routing/VivaldiZone.cpp index 449914a7b9..369e2ab4fa 100644 --- a/src/kernel/routing/VivaldiZone.cpp +++ b/src/kernel/routing/VivaldiZone.cpp @@ -60,7 +60,7 @@ static std::vector* netpoint_get_coords(NetPoint* np) } VivaldiZone::VivaldiZone(NetZoneImpl* father, std::string name, resource::NetworkModel* netmodel) - : ClusterZone(father, name, netmodel) + : ClusterZone(father, std::move(name), netmodel) { } diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 6f3d43a6ac..57c5b40022 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -23,18 +23,18 @@ namespace s4u { simgrid::xbt::Extension FileSystemStorageExt::EXTENSION_ID; simgrid::xbt::Extension FileDescriptorHostExt::EXTENSION_ID; -File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){}; +File::File(std::string fullpath, void* userdata) : File(std::move(fullpath), Host::current(), userdata){}; -File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(fullpath), userdata_(userdata) +File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(std::move(fullpath)), userdata_(userdata) { // this cannot fail because we get a xbt_die if the mountpoint does not exist Storage* st = nullptr; size_t longest_prefix_length = 0; - XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->get_cname()); + XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath_.c_str(), host->get_cname()); for (auto const& mnt : host->get_mounted_storages()) { XBT_DEBUG("See '%s'", mnt.first.c_str()); - mount_point_ = fullpath.substr(0, mnt.first.length()); + mount_point_ = fullpath_.substr(0, mnt.first.length()); if (mount_point_ == mnt.first && mnt.first.length() > longest_prefix_length) { /* The current mount name is found in the full path and is bigger than the previous*/ @@ -42,11 +42,11 @@ File::File(std::string fullpath, sg_host_t host, void* userdata) : fullpath_(ful st = mnt.second; } } - if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/ - mount_point_ = fullpath.substr(0, longest_prefix_length); - path_ = fullpath.substr(longest_prefix_length, fullpath.length()); + if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/ + mount_point_ = fullpath_.substr(0, longest_prefix_length); + path_ = fullpath_.substr(longest_prefix_length, fullpath_.length()); } else - xbt_die("Can't find mount point for '%s' on '%s'", fullpath.c_str(), host->get_cname()); + xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname()); local_storage_ = st; diff --git a/src/plugins/vm/s4u_VirtualMachine.cpp b/src/plugins/vm/s4u_VirtualMachine.cpp index 57f2503fc8..06626a8f03 100644 --- a/src/plugins/vm/s4u_VirtualMachine.cpp +++ b/src/plugins/vm/s4u_VirtualMachine.cpp @@ -25,17 +25,17 @@ simgrid::xbt::signal VirtualMachine::on_migration_start; simgrid::xbt::signal VirtualMachine::on_migration_end; VirtualMachine::VirtualMachine(std::string name, s4u::Host* physical_host, int core_amount) - : VirtualMachine(name, physical_host, core_amount, 1024) + : VirtualMachine(std::move(name), physical_host, core_amount, 1024) { } VirtualMachine::VirtualMachine(std::string name, s4u::Host* physical_host, int core_amount, size_t ramsize) - : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, physical_host, core_amount, ramsize)) + : Host(std::move(name)), pimpl_vm_(new vm::VirtualMachineImpl(this, physical_host, core_amount, ramsize)) { // xbt_assert(s4u::Host::by_name(name) == nullptr, - // "Cannot create a VM named %s: this name is already used by a host or a VM", name.c_str()); + // "Cannot create a VM named %s: this name is already used by a host or a VM", get_cname()); - XBT_DEBUG("Create VM %s", name.c_str()); + XBT_DEBUG("Create VM %s", get_cname()); /* Currently, a VM uses the network resource of its physical host */ pimpl_netpoint = physical_host->pimpl_netpoint; diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index ec1085f1b9..725cd5f9af 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -40,14 +40,15 @@ ActorPtr Actor::self() ActorPtr Actor::create(std::string name, s4u::Host* host, std::function code) { - simgrid::kernel::actor::ActorImpl* actor = simcall_process_create(name, std::move(code), nullptr, host, nullptr); + simgrid::kernel::actor::ActorImpl* actor = + simcall_process_create(std::move(name), std::move(code), nullptr, host, nullptr); return actor->iface(); } ActorPtr Actor::create(std::string name, s4u::Host* host, std::string function, std::vector args) { simgrid::simix::ActorCodeFactory& factory = SIMIX_get_actor_code_factory(function); - return create(name, host, factory(std::move(args))); + return create(std::move(name), host, factory(std::move(args))); } void intrusive_ptr_add_ref(Actor* actor) @@ -234,7 +235,7 @@ const char* Actor::get_property(std::string key) void Actor::set_property(std::string key, std::string value) { - simgrid::simix::simcall([this, key, value] { pimpl_->set_property(key, value); }); + simgrid::simix::simcall([this, key, value] { pimpl_->set_property(key, std::move(value)); }); } Actor* Actor::restart() diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 047c786681..0ecdc7292e 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -117,14 +117,14 @@ ExecPtr Exec::set_host(Host* host) ExecPtr Exec::set_name(std::string name) { xbt_assert(state_ == State::INITED, "Cannot change the name of an exec after its start"); - name_ = name; + name_ = std::move(name); return this; } ExecPtr Exec::set_tracing_category(std::string category) { xbt_assert(state_ == State::INITED, "Cannot change the tracing category of an exec after its start"); - tracing_category_ = category; + tracing_category_ = std::move(category); return this; } diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 515f776f7f..3b35113143 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -29,9 +29,9 @@ simgrid::xbt::signal Host::on_destruction; simgrid::xbt::signal Host::on_state_change; simgrid::xbt::signal Host::on_speed_change; -Host::Host(std::string name) : name_(name) +Host::Host(std::string name) : name_(std::move(name)) { - xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str()); + xbt_assert(Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", name_.c_str()); Engine::get_instance()->host_register(std::string(name_), this); new simgrid::surf::HostImpl(this); } @@ -194,7 +194,7 @@ const char* Host::get_property(std::string key) const void Host::set_property(std::string key, std::string value) { - simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); }); + simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, std::move(value)); }); } /** Specify a profile turning the host on and off according to a exhaustive list or a stochastic law. * The profile must contain boolean values. */ diff --git a/src/s4u/s4u_Link.cpp b/src/s4u/s4u_Link.cpp index d09897b673..afa6825691 100644 --- a/src/s4u/s4u_Link.cpp +++ b/src/s4u/s4u_Link.cpp @@ -111,7 +111,7 @@ const char* Link::get_property(std::string key) } void Link::set_property(std::string key, std::string value) { - simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); }); + simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, std::move(value)); }); } } // namespace s4u } // namespace simgrid diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index 211a90d360..ddb8816b00 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -39,7 +39,7 @@ const char* NetZone::get_property(std::string key) } void NetZone::set_property(std::string key, std::string value) { - simgrid::simix::simcall([this, key, value] { properties_[key] = value; }); + simgrid::simix::simcall([this, key, value] { properties_[key] = std::move(value); }); } /** @brief Returns the list of direct children (no grand-children) */ diff --git a/src/s4u/s4u_Storage.cpp b/src/s4u/s4u_Storage.cpp index 60fcd11b1e..8d0636bd1e 100644 --- a/src/s4u/s4u_Storage.cpp +++ b/src/s4u/s4u_Storage.cpp @@ -21,9 +21,9 @@ simgrid::xbt::signal Storage::on_creation; simgrid::xbt::signal Storage::on_destruction; simgrid::xbt::signal Storage::on_state_change; -Storage::Storage(std::string name, surf::StorageImpl* pimpl) : pimpl_(pimpl), name_(name) +Storage::Storage(std::string name, surf::StorageImpl* pimpl) : pimpl_(pimpl), name_(std::move(name)) { - simgrid::s4u::Engine::get_instance()->storage_register(name, this); + simgrid::s4u::Engine::get_instance()->storage_register(name_, this); } Storage* Storage::by_name(std::string name) diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index f81c789bd9..bb9357c7da 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -731,7 +731,8 @@ smx_actor_t simcall_process_create(std::string name, simgrid::simix::ActorCode c { smx_actor_t self = SIMIX_process_self(); return simgrid::simix::simcall([name, code, data, host, properties, self] { - return simgrid::kernel::actor::ActorImpl::create(name, std::move(code), data, host, properties, self).get(); + return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(code), data, host, properties, self) + .get(); }); } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index f8d41b238f..68db01c90f 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -60,7 +60,8 @@ smx_activity_t simcall_execution_parallel_start(const std::string& name, int hos xbt_assert(std::isfinite(rate), "rate is not finite!"); return simgrid::simix::simcall([name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout] { - return SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout); + return SIMIX_execution_parallel_start(std::move(name), host_nb, host_list, flops_amount, bytes_amount, rate, + timeout); }); } @@ -399,7 +400,7 @@ smx_activity_t simcall_execution_start(std::string name, std::string category, d { return simgrid::simix::simcall([name, category, flops_amount, priority, bound, host] { return simgrid::kernel::activity::ExecImplPtr( - new simgrid::kernel::activity::ExecImpl(name, category, nullptr, host)) + new simgrid::kernel::activity::ExecImpl(std::move(name), std::move(category), nullptr, host)) ->start(flops_amount, priority, bound); }); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 7bd756a321..b7ce26dd56 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -47,7 +47,7 @@ SIMIX_execution_parallel_start(std::string name, int host_nb, const sg_host_t* h } simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr( - new simgrid::kernel::activity::ExecImpl(name, "", timeout_detector, nullptr)); + new simgrid::kernel::activity::ExecImpl(std::move(name), "", timeout_detector, nullptr)); if (surf_action != nullptr) { exec->surf_action_ = surf_action; exec->surf_action_->set_data(exec.get()); diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index fc866c976b..a355263b73 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -144,7 +144,7 @@ void TRACE_internal_smpi_set_category(std::string category) TRACE_category(category.c_str()); if (not category.empty()) - process_category[SIMIX_process_self()] = category; + process_category[SIMIX_process_self()] = std::move(category); } std::string TRACE_internal_smpi_get_category() diff --git a/src/smpi/internals/smpi_deployment.cpp b/src/smpi/internals/smpi_deployment.cpp index 441d608072..2fbee2ee31 100644 --- a/src/smpi/internals/smpi_deployment.cpp +++ b/src/smpi/internals/smpi_deployment.cpp @@ -16,8 +16,8 @@ namespace app { class Instance { public: - Instance(const std::string name, int max_no_processes, MPI_Comm comm, simgrid::s4u::Barrier* finalization_barrier) - : name(name) + Instance(std::string name, int max_no_processes, MPI_Comm comm, simgrid::s4u::Barrier* finalization_barrier) + : name(std::move(name)) , size(max_no_processes) , present_processes(0) , comm_world(comm) diff --git a/src/surf/PropertyHolder.cpp b/src/surf/PropertyHolder.cpp index 53232e05ed..542ce0b06e 100644 --- a/src/surf/PropertyHolder.cpp +++ b/src/surf/PropertyHolder.cpp @@ -26,7 +26,7 @@ void PropertyHolder::set_property(std::string key, std::string value) { if (not properties_) properties_ = new std::unordered_map; - (*properties_)[key] = value; + (*properties_)[key] = std::move(value); } /** @brief Return the whole set of properties. Don't mess with it, dude! */ diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index 0053a4f8c8..be0d45f5be 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -39,10 +39,10 @@ StorageImpl::StorageImpl(kernel::resource::Model* model, std::string name, kerne std::string attach) : Resource(model, name.c_str(), maxminSystem->constraint_new(this, std::max(bread, bwrite))) , piface_(name, this) - , typeId_(type_id) - , content_name(content_name) + , typeId_(std::move(type_id)) + , content_name(std::move(content_name)) , size_(size) - , attach_(attach) + , attach_(std::move(attach)) { StorageImpl::turn_on(); XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size); diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index bb65ba4e00..3f4461ed54 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -171,7 +171,12 @@ public: StorageType(std::string id, std::string model, std::string content, std::unordered_map* properties, std::unordered_map* model_properties, sg_size_t size) - : id(id), model(model), content(content), properties(properties), model_properties(model_properties), size(size) + : id(std::move(id)) + , model(std::move(model)) + , content(std::move(content)) + , properties(properties) + , model_properties(model_properties) + , size(size) { } }; diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index a3b956a687..37e952b0a9 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -100,9 +100,9 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(std::string name, const xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name), "Refusing to create a router named '%s': this name already describes a node.", name.c_str()); - simgrid::kernel::routing::NetPoint* netpoint = - new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router, current_routing); - XBT_DEBUG("Router '%s' has the id %u", name.c_str(), netpoint->id()); + simgrid::kernel::routing::NetPoint* netpoint = new simgrid::kernel::routing::NetPoint( + std::move(name), simgrid::kernel::routing::NetPoint::Type::Router, current_routing); + XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id()); if (coords && strcmp(coords, "")) new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords); diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 2b120369e3..7a8e40aa5c 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -56,13 +56,11 @@ StorageImpl* StorageN11Model::createStorage(std::string id, std::string type_id, double Bwrite = surf_parse_get_bandwidth(storage_type->model_properties->at("Bwrite").c_str(), "property Bwrite, storage", type_id.c_str()); - StorageImpl* storage = - new StorageN11(this, id, get_maxmin_system(), Bread, Bwrite, type_id, content_name, storage_type->size, attach); - XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id.c_str(), type_id.c_str(), Bread); - return storage; + return new StorageN11(this, std::move(id), get_maxmin_system(), Bread, Bwrite, std::move(type_id), + std::move(content_name), storage_type->size, std::move(attach)); } double StorageN11Model::next_occuring_event(double now) diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index 07d839f327..405a583ac2 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -460,7 +460,7 @@ XBT_PUBLIC void declare_flag(std::string name, std::string description, T value, { if (simgrid_config == nullptr) simgrid_config = new simgrid::config::Config(); - simgrid_config->register_option(name, description, std::move(value), std::move(callback)); + simgrid_config->register_option(name, std::move(description), std::move(value), std::move(callback)); } template XBT_PUBLIC void declare_flag(std::string name, std::string description, int value, diff --git a/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp b/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp index ec01f8cf22..4121731c16 100644 --- a/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp +++ b/teshsuite/s4u/cloud-sharing/cloud-sharing.cpp @@ -42,7 +42,7 @@ static int computation_fun(std::vector argv) static void run_test_process(std::string name, simgrid::s4u::Host *location, int size) { std::vector arg = {std::to_string(size)}; - simgrid::s4u::Actor::create(name, location, computation_fun, arg); + simgrid::s4u::Actor::create(std::move(name), location, computation_fun, arg); } static void test_energy_consumption(std::string name, int nb_cores)