Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove explicit conversion to std::string when it's not required.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 7 Nov 2022 15:03:13 +0000 (16:03 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 8 Nov 2022 08:43:10 +0000 (09:43 +0100)
Some of them were redundant.
Some of them became optional after the removal of xbt::string.

91 files changed:
docs/source/Tutorial_Algorithms.rst
docs/source/tuto_s4u/master-workers-lab1.cpp
docs/source/tuto_s4u/master-workers-lab2.cpp
docs/source/tuto_s4u/master-workers-lab3.cpp
docs/source/tuto_s4u/master-workers-lab4.cpp
examples/cpp/activity-testany/s4u-activity-testany.cpp
examples/cpp/activity-waitany/s4u-activity-waitany.cpp
examples/cpp/app-chainsend/s4u-app-chainsend.cpp
examples/cpp/cloud-simple/s4u-cloud-simple.cpp
examples/cpp/clusters-multicpu/s4u-clusters-multicpu.cpp
examples/cpp/comm-ready/s4u-comm-ready.cpp
examples/cpp/comm-serialize/s4u-comm-serialize.cpp
examples/cpp/comm-testany/s4u-comm-testany.cpp
examples/cpp/comm-wait/s4u-comm-wait.cpp
examples/cpp/comm-waitall/s4u-comm-waitall.cpp
examples/cpp/comm-waitany/s4u-comm-waitany.cpp
examples/cpp/comm-waituntil/s4u-comm-waituntil.cpp
examples/cpp/energy-link/s4u-energy-link.cpp
examples/cpp/exec-waitany/s4u-exec-waitany.cpp
examples/cpp/network-factors/s4u-network-factors.cpp
examples/cpp/network-nonlinear/s4u-network-nonlinear.cpp
examples/cpp/platform-failures/s4u-platform-failures.cpp
examples/cpp/platform-profile/s4u-platform-profile.cpp
examples/cpp/plugin-prodcons/s4u-plugin-prodcons.cpp
examples/cpp/replay-comm/s4u-replay-comm.cpp
examples/cpp/synchro-condition-variable/s4u-synchro-condition-variable.cpp
include/simgrid/Exception.hpp
include/simgrid/instr.h
include/simgrid/plugins/ProducerConsumer.hpp
include/xbt/config.hpp
src/bindings/java/jmsg_comm.cpp
src/bindings/java/jmsg_process.cpp
src/bindings/java/jxbt_utilities.hpp
src/bindings/python/simgrid_python.cpp
src/dag/loaders.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_platform.cpp
src/kernel/EngineImpl.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/CommObserver.cpp
src/kernel/actor/SimcallObserver.cpp
src/kernel/resource/FactorSet.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/mc/ModelChecker.hpp
src/mc/inspect/mc_dwarf.cpp
src/mc/remote/RemoteProcess.cpp
src/mc/sosp/Snapshot.cpp
src/msg/msg_private.hpp
src/msg/msg_task.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_dvfs.cpp
src/plugins/host_energy.cpp
src/plugins/link_energy.cpp
src/plugins/link_energy_wifi.cpp
src/plugins/vm/VmLiveMigration.cpp
src/plugins/vm/VmLiveMigration.hpp
src/s4u/s4u_Engine.cpp
src/s4u/s4u_Host.cpp
src/s4u/s4u_Link.cpp
src/s4u/s4u_Netzone.cpp
src/s4u/s4u_VirtualMachine.cpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/colls/smpi_coll.cpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_group.hpp
src/smpi/include/smpi_info.hpp
src/smpi/include/smpi_request.hpp
src/smpi/include/smpi_win.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_file.cpp
src/surf/HostImpl.cpp
src/surf/sg_platf.cpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/backtrace.cpp
src/xbt/config.cpp
src/xbt/log.cpp
src/xbt/memory_map.cpp
src/xbt/xbt_os_file.cpp
src/xbt/xbt_parse_units.cpp
src/xbt/xbt_replay.cpp
teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp
teshsuite/s4u/seal-platform/seal-platform.cpp

index 8adaa60..7d9ca41 100644 (file)
@@ -636,8 +636,8 @@ information is only written once. It thus follows the `DRY
       .. code-block:: cpp
 
          for (int i = 0; i < tasks_count; i++) {
-            std::string worker_rank          = std::to_string(i % workers_count);
-            std::string mailbox_name         = std::string("worker-") + worker_rank;
+            std::string worker_rank        = std::to_string(i % workers_count);
+            std::string mailbox_name       = "worker-" + worker_rank;
             simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
             mailbox->put(...);
index 7b6fbb6..c6f879c 100644 (file)
@@ -29,9 +29,9 @@ static void master(std::vector<std::string> args)
 
   for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
     /* - Select a worker in a round-robin way */
-    std::string worker_rank          = std::to_string(i % workers_count);
-    std::string mailbox_name         = std::string("worker-") + worker_rank;
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    std::string worker_rank        = std::to_string(i % workers_count);
+    std::string mailbox_name       = "worker-" + worker_rank;
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     /* - Send the computation cost to that worker */
     XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
@@ -41,8 +41,8 @@ static void master(std::vector<std::string> args)
   XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
   for (int i = 0; i < workers_count; i++) {
     /* The workers stop when receiving a negative compute_cost */
-    std::string mailbox_name         = std::string("worker-") + std::to_string(i);
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    std::string mailbox_name       = "worker-" + std::to_string(i);
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     mailbox->put(new double(-1.0), 0);
   }
@@ -53,8 +53,8 @@ static void worker(std::vector<std::string> args)
   xbt_assert(args.size() == 2, "The worker expects a single argument");
   long id = std::stol(args[1]);
 
-  const std::string mailbox_name   = std::string("worker-") + std::to_string(id);
-  simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+  const std::string mailbox_name = "worker-" + std::to_string(id);
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
   double compute_cost;
   do {
index 231a705..39faad2 100644 (file)
@@ -18,8 +18,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e
 
 static void worker()
 {
-  const std::string mailbox_name   = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
-  simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+  const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
   double compute_cost;
   do {
@@ -45,7 +45,7 @@ static void master(std::vector<std::string> args)
   std::vector<simgrid::s4u::ActorPtr> actors;
 
   for (auto* host : simgrid::s4u::Engine::get_instance()->get_all_hosts()) {
-    simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker);
+    simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker);
     actors.push_back(act);
   }
 
@@ -53,9 +53,9 @@ static void master(std::vector<std::string> args)
 
   for (int i = 0; i < tasks_count; i++) { /* For each task to be executed: */
     /* - Select a worker in a round-robin way */
-    aid_t worker_pid                 = actors.at(i % actors.size())->get_pid();
-    std::string mailbox_name         = std::string("worker-") + std::to_string(worker_pid);
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    aid_t worker_pid               = actors.at(i % actors.size())->get_pid();
+    std::string mailbox_name       = "worker-" + std::to_string(worker_pid);
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     /* - Send the computation cost to that worker */
     XBT_INFO("Sending task %d of %ld to mailbox '%s'", i, tasks_count, mailbox->get_cname());
@@ -65,8 +65,8 @@ static void master(std::vector<std::string> args)
   XBT_INFO("All tasks have been dispatched. Request all workers to stop.");
   for (unsigned long i = 0; i < actors.size(); i++) {
     /* The workers stop when receiving a negative compute_cost */
-    std::string mailbox_name         = std::string("worker-") + std::to_string(actors.at(i)->get_pid());
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    std::string mailbox_name       = "worker-" + std::to_string(actors.at(i)->get_pid());
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     mailbox->put(new double(-1.0), 0);
   }
index 2f10f58..e1f44a1 100644 (file)
@@ -18,8 +18,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e
 
 static void worker()
 {
-  const std::string mailbox_name   = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
-  simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+  const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
   while (true) { // Master forcefully kills the workers by the end of the simulation
     double* msg         = mailbox->get<double>();
@@ -45,16 +45,16 @@ static void master(std::vector<std::string> args)
   XBT_INFO("Asked to run for %.1f seconds", simulation_duration);
 
   for (auto* host : e->get_all_hosts()) {
-    simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker);
+    simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker);
     actors.push_back(act);
   }
 
   int task_id = 0;
   while (simgrid::s4u::Engine::get_clock() < simulation_duration) { /* For each task: */
     /* - Select a worker in a round-robin way */
-    aid_t worker_pid                 = actors.at(task_id % actors.size())->get_pid();
-    std::string mailbox_name         = std::string("worker-") + std::to_string(worker_pid);
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    aid_t worker_pid               = actors.at(task_id % actors.size())->get_pid();
+    std::string mailbox_name       = "worker-" + std::to_string(worker_pid);
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     /* - Send the computation cost to that worker */
     if (task_id % 100 == 0)
index 3cc8ff2..6973e69 100644 (file)
@@ -18,8 +18,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_masterworker, "Messages specific for this e
 
 static void worker(std::string category)
 {
-  const std::string mailbox_name   = std::string("worker-") + std::to_string(simgrid::s4u::this_actor::get_pid());
-  simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+  const std::string mailbox_name = "worker-" + std::to_string(simgrid::s4u::this_actor::get_pid());
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
   while (true) { // Master forcefully kills the workers by the end of the simulation
     double* msg         = mailbox->get<double>();
@@ -45,22 +45,21 @@ static void master(std::vector<std::string> args)
   std::vector<simgrid::s4u::ActorPtr> actors;
 
   simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
-  std::string my_name     = std::string("master-") + std::to_string(simgrid::s4u::this_actor::get_pid());
+  std::string my_name     = "master-" + std::to_string(simgrid::s4u::this_actor::get_pid());
 
   XBT_INFO("Asked to run for %.1f seconds", simulation_duration);
 
   for (auto* host : e->get_all_hosts()) {
-    simgrid::s4u::ActorPtr act =
-        simgrid::s4u::Actor::create(std::string("Worker-") + host->get_name(), host, worker, my_name);
+    simgrid::s4u::ActorPtr act = simgrid::s4u::Actor::create("Worker-" + host->get_name(), host, worker, my_name);
     actors.push_back(act);
   }
 
   int task_id = 0;
   while (simgrid::s4u::Engine::get_clock() < simulation_duration) { /* For each task: */
     /* - Select a worker in a round-robin way */
-    aid_t worker_pid                 = actors.at(task_id % actors.size())->get_pid();
-    std::string mailbox_name         = std::string("worker-") + std::to_string(worker_pid);
-    simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(mailbox_name);
+    aid_t worker_pid               = actors.at(task_id % actors.size())->get_pid();
+    std::string mailbox_name       = "worker-" + std::to_string(worker_pid);
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(mailbox_name);
 
     /* - Send the computation cost to that worker */
     XBT_DEBUG("Sending task %d to mailbox '%s'", task_id, mailbox->get_cname());
index 6dc8769..5a8a651 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_activity_testany, "Messages specific for this s
 
 static void bob()
 {
-  sg4::Mailbox* mbox    = sg4::Mailbox::by_name(std::string("mbox"));
+  sg4::Mailbox* mbox    = sg4::Mailbox::by_name("mbox");
   const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
   std::string* payload;
 
@@ -54,7 +54,7 @@ static void alice()
 {
   auto* payload = new std::string("Message");
   XBT_INFO("Send '%s'", payload->c_str());
-  sg4::Mailbox::by_name(std::string("mbox"))->put(payload, 6e8);
+  sg4::Mailbox::by_name("mbox")->put(payload, 6e8);
 }
 
 int main(int argc, char* argv[])
index aa13b41..83a6842 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_activity_waittany, "Messages specific for this
 
 static void bob()
 {
-  sg4::Mailbox* mbox    = sg4::Mailbox::by_name(std::string("mbox"));
+  sg4::Mailbox* mbox    = sg4::Mailbox::by_name("mbox");
   const sg4::Disk* disk = sg4::Host::current()->get_disks().front();
   std::string* payload;
 
@@ -48,7 +48,7 @@ static void alice()
 {
   auto* payload = new std::string("Message");
   XBT_INFO("Send '%s'", payload->c_str());
-  sg4::Mailbox::by_name(std::string("mbox"))->put(payload, 6e8);
+  sg4::Mailbox::by_name("mbox")->put(payload, 6e8);
 }
 
 int main(int argc, char* argv[])
index bddfeb4..27484ce 100644 (file)
@@ -123,7 +123,7 @@ public:
   Broadcaster(int hostcount, unsigned int piece_count) : piece_count(piece_count)
   {
     for (int i = 1; i <= hostcount; i++) {
-      std::string name = std::string("node-") + std::to_string(i) + ".simgrid.org";
+      std::string name = "node-" + std::to_string(i) + ".simgrid.org";
       XBT_DEBUG("%s", name.c_str());
       mailboxes.push_back(sg4::Mailbox::by_name(name));
     }
index 9c5134c..90373f1 100644 (file)
@@ -57,7 +57,7 @@ static void communication_rx_fun(std::vector<std::string> args)
 
 static void launch_communication_worker(s4u_Host* tx_host, s4u_Host* rx_host)
 {
-  std::string mbox_name = std::string("MBOX:") + tx_host->get_cname() + "-" + rx_host->get_cname();
+  std::string mbox_name = "MBOX:" + tx_host->get_name() + "-" + rx_host->get_name();
   std::vector<std::string> args;
   args.push_back(mbox_name);
 
index 8ae7a7a..db613f6 100644 (file)
@@ -30,8 +30,7 @@ public:
     std::vector<sg4::Mailbox*> mboxes;
 
     /* Start dispatching 1 message to all receivers */
-    std::string msg_content =
-        std::string("Hello, I'm alive and running on ") + std::string(sg4::this_actor::get_host()->get_name());
+    std::string msg_content = "Hello, I'm alive and running on " + sg4::this_actor::get_host()->get_name();
     for (const auto* host : hosts_) {
       /* Copy the data we send: the 'msg_content' variable is not a stable storage location.
        * It will be destroyed when this actor leaves the loop, ie before the receiver gets it */
@@ -307,7 +306,7 @@ int main(int argc, char* argv[])
   sg4::Actor::create("sender", host_list[0], Sender(host_list));
   /* create receiver in every host */
   for (auto* host : host_list) {
-    sg4::Actor::create(std::string("receiver-") + std::string(host->get_name()), host, Receiver());
+    sg4::Actor::create("receiver-" + host->get_name(), host, Receiver());
   }
 
   /* runs the simulation */
index edb9575..d90d52d 100644 (file)
@@ -30,7 +30,7 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
 {
   /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
    * into it */
-  sg4::Mailbox* my_mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(my_id));
+  sg4::Mailbox* my_mbox = sg4::Mailbox::by_name("peer-" + std::to_string(my_id));
   my_mbox->set_receiver(sg4::Actor::self());
 
   std::vector<sg4::CommPtr> pending_comms;
@@ -39,8 +39,8 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
   for (int i = 0; i < messages_count; i++) {
     for (int peer_id = 0; peer_id < peers_count; peer_id++) {
       if (peer_id != my_id) {
-        sg4::Mailbox* mbox  = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
-        std::string message = std::string("Message ") + std::to_string(i) + " from peer " + std::to_string(my_id);
+        sg4::Mailbox* mbox  = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
+        std::string message = "Message " + std::to_string(i) + " from peer " + std::to_string(my_id);
         auto* payload       = new std::string(message); // copy the data we send:
         // 'message' is not a stable storage location
         XBT_INFO("Send '%s' to '%s'", message.c_str(), mbox->get_cname());
@@ -53,7 +53,7 @@ static void peer(int my_id, int messages_count, size_t payload_size, int peers_c
   /* Start sending messages to let peers know that they should stop */
   for (int peer_id = 0; peer_id < peers_count; peer_id++) {
     if (peer_id != my_id) {
-      sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("peer-") + std::to_string(peer_id));
+      sg4::Mailbox* mbox = sg4::Mailbox::by_name("peer-" + std::to_string(peer_id));
       auto* payload      = new std::string("finalize"); // Make a copy of the data we will send
       pending_comms.push_back(mbox->put_async(payload, payload_size));
       XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
index 4c81a75..d7d25ba 100644 (file)
@@ -39,7 +39,7 @@ public:
 
     /* Start dispatching all messages to receiver */
     for (int i = 0; i < messages_count; i++) {
-      std::string msg_content = std::string("Message ") + std::to_string(i);
+      std::string msg_content = "Message " + std::to_string(i);
       // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
       auto* payload = new std::string(msg_content);
index 3c673c8..a519a4a 100644 (file)
@@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_testany, "Messages specific for this s4u e
 
 static void rank0()
 {
-  sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("rank0"));
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("rank0");
   std::string* msg1;
   std::string* msg2;
   std::string* msg3;
@@ -26,7 +26,7 @@ static void rank0()
 
   XBT_INFO("Send some data to rank-1");
   for (int i = 0; i < 3; i++)
-    sg4::Mailbox::by_name(std::string("rank1"))->put(new int(i), 1);
+    sg4::Mailbox::by_name("rank1")->put(new int(i), 1);
 
   XBT_INFO("Test for completed comms");
   while (not pending_comms.empty()) {
@@ -45,13 +45,13 @@ static void rank0()
 
 static void rank1()
 {
-  sg4::Mailbox* rank0_mbox = sg4::Mailbox::by_name(std::string("rank0"));
-  sg4::Mailbox* rank1_mbox = sg4::Mailbox::by_name(std::string("rank1"));
+  sg4::Mailbox* rank0_mbox = sg4::Mailbox::by_name("rank0");
+  sg4::Mailbox* rank1_mbox = sg4::Mailbox::by_name("rank1");
 
   for (int i = 0; i < 3; i++) {
     auto res = rank1_mbox->get_unique<int>();
     XBT_INFO("Received %d", *res);
-    std::string msg_content = std::string("Message ") + std::to_string(i);
+    std::string msg_content = "Message " + std::to_string(i);
     auto* payload           = new std::string(msg_content);
     XBT_INFO("Send '%s'", msg_content.c_str());
     rank0_mbox->put(payload, 1e6);
index 74edc64..6ec1b67 100644 (file)
@@ -30,7 +30,7 @@ static void sender(int messages_count, size_t payload_size)
   sg4::this_actor::sleep_for(sleep_start_time);
 
   for (int i = 0; i < messages_count; i++) {
-    std::string msg_content = std::string("Message ") + std::to_string(i);
+    std::string msg_content = "Message " + std::to_string(i);
     // Copy the data we send: the 'msg_content' variable is not a stable storage location.
     // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
     auto* payload = new std::string(msg_content);
index c0b3473..19431a0 100644 (file)
@@ -33,12 +33,12 @@ static void sender(unsigned int messages_count, unsigned int receivers_count, lo
   /* Make a vector of the mailboxes to use */
   std::vector<sg4::Mailbox*> mboxes;
   for (unsigned int i = 0; i < receivers_count; i++)
-    mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
+    mboxes.push_back(sg4::Mailbox::by_name("receiver-" + std::to_string(i)));
   // sphinx-doc: init-end
 
   /* Start dispatching all messages to receivers, in a round robin fashion */
   for (unsigned int i = 0; i < messages_count; i++) {
-    std::string msg_content = std::string("Message ") + std::to_string(i);
+    std::string msg_content = "Message " + std::to_string(i);
     // Copy the data we send: the 'msg_content' variable is not a stable storage location.
     // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
     auto* payload = new std::string(msg_content);
@@ -68,7 +68,7 @@ static void sender(unsigned int messages_count, unsigned int receivers_count, lo
 /* Receiver actor expects 1 argument: its ID */
 static void receiver(int id)
 {
-  sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(id));
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-" + std::to_string(id));
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
     auto received = mbox->get_unique<std::string>();
index 30cd1e7..5d343fc 100644 (file)
@@ -37,11 +37,11 @@ static void sender(unsigned int messages_count, unsigned int receivers_count, lo
   /* Make a vector of the mailboxes to use */
   std::vector<sg4::Mailbox*> mboxes;
   for (unsigned int i = 0; i < receivers_count; i++)
-    mboxes.push_back(sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(i)));
+    mboxes.push_back(sg4::Mailbox::by_name("receiver-" + std::to_string(i)));
 
   /* Start dispatching all messages to receivers, in a round robin fashion */
   for (unsigned int i = 0; i < messages_count; i++) {
-    std::string msg_content = std::string("Message ") + std::to_string(i);
+    std::string msg_content = "Message " + std::to_string(i);
     // Copy the data we send: the 'msg_content' variable is not a stable storage location.
     // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
     auto* payload = new std::string(msg_content);
@@ -81,7 +81,7 @@ static void sender(unsigned int messages_count, unsigned int receivers_count, lo
 /* Receiver actor expects 1 argument: its ID */
 static void receiver(int id)
 {
-  sg4::Mailbox* mbox = sg4::Mailbox::by_name(std::string("receiver-") + std::to_string(id));
+  sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-" + std::to_string(id));
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
     auto received = mbox->get_unique<std::string>();
index a24ca3a..dc61966 100644 (file)
@@ -25,7 +25,7 @@ static void sender(int messages_count, size_t payload_size)
 
   /* Start dispatching all messages to the receiver */
   for (int i = 0; i < messages_count; i++) {
-    std::string message = std::string("Message ") + std::to_string(i);
+    std::string message = "Message " + std::to_string(i);
     auto* payload       = new std::string(message); // copy the data we send:
 
     // 'msgName' is not a stable storage location
index 66e849c..d803025 100644 (file)
@@ -22,7 +22,7 @@ static void sender(std::vector<std::string> args)
   long comm_size  = std::stol(args.at(1));
   XBT_INFO("Send %ld bytes, in %d flows", comm_size, flow_amount);
 
-  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name("message");
 
   /* Sleep a while before starting the example */
   sg4::this_actor::sleep_for(10);
@@ -47,7 +47,7 @@ static void receiver(std::vector<std::string> args)
 
   XBT_INFO("Receiving %d flows ...", flow_amount);
 
-  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("message"));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name("message");
 
   if (flow_amount == 1) {
     char* res = mailbox->get<char>();
index 1a2b87d..ec5f495 100644 (file)
@@ -17,7 +17,7 @@ static void worker(bool with_timeout)
   std::vector<sg4::ExecPtr> pending_executions;
 
   for (int i = 0; i < 3; i++) {
-    std::string name = std::string("Exec-") + std::to_string(i);
+    std::string name = "Exec-" + std::to_string(i);
     double amount    = (6 * (i % 2) + i + 1) * sg4::this_actor::get_host()->get_speed();
 
     sg4::ExecPtr exec = sg4::this_actor::exec_init(amount)->set_name(name);
index abeeab7..70695f0 100644 (file)
@@ -235,10 +235,9 @@ int main(int argc, char* argv[])
 
   sg4::Host* host        = e.host_by_name("dahu-1.grid5000.fr");
   sg4::Host* host_remote = e.host_by_name("dahu-10.grid5000.fr");
-  sg4::Actor::create(std::string("receiver-local"), host, Receiver());
-  sg4::Actor::create(std::string("receiver-remote"), host_remote, Receiver());
-  sg4::Actor::create(std::string("sender") + std::string(host->get_name()), host,
-                     Sender({host, host_remote}, crosstraffic));
+  sg4::Actor::create("receiver-local", host, Receiver());
+  sg4::Actor::create("receiver-remote", host_remote, Receiver());
+  sg4::Actor::create("sender" + host->get_name(), host, Sender({host, host_remote}, crosstraffic));
 
   /* runs the simulation */
   e.run();
index 292503e..b065a79 100644 (file)
@@ -32,7 +32,7 @@ public:
 
     /* Start dispatching all messages to receiver */
     for (int i = 0; i < messages_count; i++) {
-      std::string msg_content = std::string("Message ") + std::to_string(i);
+      std::string msg_content = "Message " + std::to_string(i);
       // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
       auto* payload           = new std::string(msg_content);
index c728cd3..339b474 100644 (file)
@@ -38,7 +38,7 @@ static void master(std::vector<std::string> args)
   XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
 
   for (int i = 0; i < number_of_tasks; i++) {
-    mailbox         = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(i % workers_count));
+    mailbox         = sg4::Mailbox::by_name("worker-" + std::to_string(i % workers_count));
     auto* payload   = new double(comp_size);
     try {
       XBT_INFO("Send a message to %s", mailbox->get_cname());
@@ -56,7 +56,7 @@ static void master(std::vector<std::string> args)
   XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
   for (int i = 0; i < workers_count; i++) {
     /* - Eventually tell all the workers to stop by sending a "finalize" task */
-    mailbox         = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(i));
+    mailbox         = sg4::Mailbox::by_name("worker-" + std::to_string(i));
     auto* payload   = new double(-1.0);
     try {
       mailbox->put(payload, 0, 1.0);
@@ -76,7 +76,7 @@ static void worker(std::vector<std::string> args)
 {
   xbt_assert(args.size() == 2, "Expecting one parameter");
   long id               = std::stol(args[1]);
-  sg4::Mailbox* mailbox = sg4::Mailbox::by_name(std::string("worker-") + std::to_string(id));
+  sg4::Mailbox* mailbox = sg4::Mailbox::by_name("worker-" + std::to_string(id));
   while (true) {
     try {
       XBT_INFO("Waiting a message on %s", mailbox->get_cname());
index 5e3602a..7fad09b 100644 (file)
@@ -26,7 +26,7 @@ static void watcher()
 
   std::string path;
   for (const auto* l : links)
-    path += (path.empty() ? "" : ", ") + std::string("link '") + l->get_name() + std::string("'");
+    path += std::string(path.empty() ? "" : ", ") + "link '" + l->get_name() + "'";
   XBT_INFO("Path from Jupiter to Fafard: %s (latency: %fs).", path.c_str(), lat);
 
   for (int i = 0; i < 10; i++) {
index 6ef625f..f023e78 100644 (file)
@@ -58,11 +58,11 @@ int main(int argc, char* argv[])
   // Platform creation
   auto* cluster = sg4::create_star_zone("cluster");
   for (int i = 0; i < 8; i++) {
-    std::string hostname = std::string("node-") + std::to_string(i) + ".simgrid.org";
+    std::string hostname = "node-" + std::to_string(i) + ".simgrid.org";
 
     const auto* host = cluster->create_host(hostname, "1Gf");
 
-    std::string linkname = std::string("cluster") + "_link_" + std::to_string(i);
+    std::string linkname = "cluster_link_" + std::to_string(i);
     const auto* link     = cluster->create_split_duplex_link(linkname, "1Gbps");
 
     cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, {{link, sg4::LinkInRoute::Direction::UP}},
@@ -78,10 +78,10 @@ int main(int argc, char* argv[])
   XBT_INFO("Transfers are done in %s mode", pc->get_transfer_mode().c_str());
 
   for (int i = 0; i < 3; i++) {
-    std::string hostname = std::string("node-") + std::to_string(i) + ".simgrid.org";
+    std::string hostname = "node-" + std::to_string(i) + ".simgrid.org";
     sg4::Actor::create("ingester-" + std::to_string(i), e.host_by_name(hostname), &ingester, i, pc);
 
-    hostname = std::string("node-") + std::to_string(i + 3) + ".simgrid.org";
+    hostname = "node-" + std::to_string(i + 3) + ".simgrid.org";
     sg4::Actor::create("retriever-" + std::to_string(i), e.host_by_name(hostname), &retriever, pc);
   }
 
index e53af5b..f4052a1 100644 (file)
@@ -71,7 +71,7 @@ public:
   static void recv(simgrid::xbt::ReplayAction& action)
   {
     double clock       = sg4::Engine::get_clock();
-    sg4::Mailbox* from = sg4::Mailbox::by_name(std::string(action[2]) + "_" + sg4::this_actor::get_name());
+    sg4::Mailbox* from = sg4::Mailbox::by_name(action[2] + "_" + sg4::this_actor::get_name());
 
     ACT_DEBUG("Receiving: %s -- Actor %s on mailbox %s", NAME.c_str(), sg4::this_actor::get_cname(), from->get_cname());
     from->get_unique<std::string>();
index 3602e1d..07edf8a 100644 (file)
@@ -17,7 +17,7 @@ static void worker_fun(sg4::ConditionVariablePtr cv, sg4::MutexPtr mutex)
   std::unique_lock lock(*mutex);
 
   XBT_INFO("Start processing data which is '%s'.", data.c_str());
-  data += std::string(" after processing");
+  data += " after processing";
 
   // Send data back to main()
   XBT_INFO("Signal to master that the data processing is completed, and exit.");
@@ -30,7 +30,7 @@ static void master_fun()
 {
   auto mutex  = sg4::Mutex::create();
   auto cv     = sg4::ConditionVariable::create();
-  data        = std::string("Example data");
+  data        = "Example data";
   auto worker = sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker_fun, cv, mutex);
 
   // wait for the worker
index 342bd4b..d09e6a8 100644 (file)
@@ -183,9 +183,7 @@ class XBT_PUBLIC ForcefulKillException {
    */
 public:
   ForcefulKillException() = default;
-  explicit ForcefulKillException(const std::string& msg) : msg_(std::string("Actor killed (") + msg + std::string(")."))
-  {
-  }
+  explicit ForcefulKillException(const std::string& msg) : msg_("Actor killed (" + msg + ").") {}
   ~ForcefulKillException();
   const char* what() const noexcept { return msg_.c_str(); }
 
@@ -193,7 +191,7 @@ public:
   static bool try_n_catch(const std::function<void()>& try_block);
 
 private:
-  std::string msg_ = std::string("Actor killed.");
+  std::string msg_ = "Actor killed.";
 };
 
 } // namespace simgrid
index cff5436..df7036c 100644 (file)
@@ -17,7 +17,7 @@ namespace simgrid {
 namespace instr {
 /* User-variables related functions*/
 /* for host variables */
-XBT_PUBLIC void declare_host_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_host_variable(const std::string& variable, const std::string& color = "");
 XBT_PUBLIC void set_host_variable(const std::string& host, const std::string& variable, double value,
                                   double time = simgrid_get_clock());
 XBT_PUBLIC void add_host_variable(const std::string& host, const std::string& variable, double value,
@@ -27,7 +27,7 @@ XBT_PUBLIC void sub_host_variable(const std::string& host, const std::string& va
 XBT_PUBLIC const std::set<std::string, std::less<>>& get_host_variables();
 
 /* for link variables */
-XBT_PUBLIC void declare_link_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_link_variable(const std::string& variable, const std::string& color = "");
 XBT_PUBLIC void set_link_variable(const std::string& link, const std::string& variable, double value,
                                   double time = simgrid_get_clock());
 XBT_PUBLIC void add_link_variable(const std::string& link, const std::string& variable, double value,
@@ -44,7 +44,7 @@ XBT_PUBLIC void sub_link_variable(const std::string& src, const std::string& dst
 XBT_PUBLIC const std::set<std::string, std::less<>>& get_link_variables();
 
 /* for VM variables */
-XBT_PUBLIC void declare_vm_variable(const std::string& variable, const std::string& color = std::string(""));
+XBT_PUBLIC void declare_vm_variable(const std::string& variable, const std::string& color = "");
 XBT_PUBLIC void set_vm_variable(const std::string& vm, const std::string& variable, double value,
                                 double time = simgrid_get_clock());
 XBT_PUBLIC void add_vm_variable(const std::string& vm, const std::string& variable, double value,
@@ -56,7 +56,7 @@ XBT_PUBLIC const std::set<std::string, std::less<>>& get_vm_variables();
 /*  Functions to manage tracing marks (used for trace comparison experiments) */
 XBT_PUBLIC void declare_mark(const std::string& mark_type);
 XBT_PUBLIC void declare_mark_value(const std::string& mark_type, const std::string& mark_value,
-                                   const std::string& mark_color = std::string("1 1 1"));
+                                   const std::string& mark_color = "1 1 1");
 XBT_PUBLIC void mark(const std::string& mark_type, const std::string& mark_value);
 XBT_PUBLIC const std::set<std::string, std::less<>>& get_marks();
 
index 6f4f909..45f7cd0 100644 (file)
@@ -75,7 +75,7 @@ private:
   {
     xbt_assert(max_queue_size > 0, "Max queue size of 0 is not allowed");
 
-    id = std::string("ProducerConsumer") + std::to_string(pc_id);
+    id = "ProducerConsumer" + std::to_string(pc_id);
     pc_id++;
 
     mutex_   = s4u::Mutex::create();
index 397870e..a02a076 100644 (file)
@@ -174,7 +174,7 @@ bind_flag(std::string& value, const char* name, const char* description,
                  if (val == "help")
                    mesg += std::string("Possible values for option ") + name + ":\n";
                  else
-                   mesg += std::string("Invalid value '") + val + "' for option " + name + ". Possible values:\n";
+                   mesg += "Invalid value '" + val + "' for option " + name + ". Possible values:\n";
                  for (auto const& kv : valid_values)
                    mesg += "  - '" + kv.first + "': " + kv.second + (kv.first == value ? "  <=== DEFAULT" : "") + "\n";
                  xbt_die("%s", mesg.c_str());
index 0eaa12d..ce0d030 100644 (file)
@@ -128,7 +128,7 @@ static msg_comm_t* jarray_to_commArray(JNIEnv *env, jobjectArray jcomms, /* OUT
 
      comms[i] = (msg_comm_t) (uintptr_t) env->GetLongField(jcomm, jcomm_field_Comm_bind);
      if (not comms[i]) {
-       jxbt_throw_null(env, std::string("comm at rank ") + std::to_string(i) + " is null");
+       jxbt_throw_null(env, "comm at rank " + std::to_string(i) + " is null");
        return nullptr;
      }
 
index ffbf7ff..a561d17 100644 (file)
@@ -114,7 +114,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID(JNIEnv * env, jcl
   auto const* actor = sg_actor_by_pid(pid);
 
   if (not actor) {
-    jxbt_throw_process_not_found(env, std::string("PID = ") + std::to_string(static_cast<int>(pid)));
+    jxbt_throw_process_not_found(env, "PID = " + std::to_string(static_cast<int>(pid)));
     return nullptr;
   }
 
index 63988ba..919ac6e 100644 (file)
@@ -84,7 +84,7 @@ public:
       env_->ReleaseStringUTFChars(jstr_, value);
   }
   operator const char*() const { return value; }
-  operator const std::string() const { return std::string(value); }
+  operator const std::string() const { return value; }
 };
 
 #endif
index 8aad6d5..51b42fb 100644 (file)
@@ -641,7 +641,7 @@ PYBIND11_MODULE(simgrid, m)
   py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(
       m, "Mailbox", "Mailbox. See the C++ documentation for details.")
       .def(
-          "__str__", [](const Mailbox* self) { return std::string("Mailbox(") + self->get_cname() + ")"; },
+          "__str__", [](const Mailbox* self) { return "Mailbox(" + self->get_name() + ")"; },
           "Textual representation of the Mailbox`")
       .def_static("by_name", &Mailbox::by_name, py::call_guard<py::gil_scoped_release>(), py::arg("name"),
                   "Retrieve a Mailbox from its name")
@@ -716,7 +716,7 @@ PYBIND11_MODULE(simgrid, m)
                              "Retrieve the mailbox on which this comm acts.")
       .def_property_readonly("sender", &Comm::get_sender,
                              py::call_guard<py::gil_scoped_release>())
-      .def_property_readonly("state_str", [](const Comm* self){ return std::string(self->get_state_str()); },
+      .def_property_readonly("state_str", &Comm::get_state_str,
                              py::call_guard<py::gil_scoped_release>(),
                              "Retrieve the Comm state as string")
       .def_property_readonly("remaining",  &Comm::get_remaining,
index c6d288d..bba69d8 100644 (file)
@@ -295,7 +295,7 @@ std::vector<ActivityPtr> create_DAG_from_dot(const std::string& filename)
 void STag_dax__adag()
 {
   try {
-    double version = std::stod(std::string(A_dax__adag_version));
+    double version = std::stod(A_dax__adag_version);
     xbt_assert(version == 2.1, "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file", version);
   } catch (const std::invalid_argument&) {
     throw std::invalid_argument(std::string("Parse error: ") + A_dax__adag_version + " is not a double");
@@ -305,7 +305,7 @@ void STag_dax__adag()
 void STag_dax__job()
 {
   try {
-    double runtime = std::stod(std::string(A_dax__job_runtime));
+    double runtime = std::stod(A_dax__job_runtime);
 
     std::string name = std::string(A_dax__job_id) + "@" + A_dax__job_name;
     runtime *= 4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
@@ -322,7 +322,7 @@ void STag_dax__uses()
 {
   double size;
   try {
-    size = std::stod(std::string(A_dax__uses_size));
+    size = std::stod(A_dax__uses_size);
   } catch (const std::invalid_argument&) {
     throw std::invalid_argument(std::string("Parse error: ") + A_dax__uses_size + " is not a double");
   }
@@ -357,7 +357,7 @@ void STag_dax__child()
   if (job != simgrid::s4u::jobs.end()) {
     current_child = job->second;
   } else {
-    throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
+    throw std::out_of_range("Parse error on line " + std::to_string(dax_lineno) +
                             ": Asked to add dependencies to the non-existent " + A_dax__child_ref + "task");
   }
 }
@@ -375,9 +375,9 @@ void STag_dax__parent()
     parent->add_successor(current_child);
     XBT_DEBUG("Control-flow dependency from %s to %s", current_child->get_cname(), parent->get_cname());
   } else {
-    throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
-                            ": Asked to add a dependency from " + current_child->get_name() + " to " +
-                            A_dax__parent_ref + ", but " + A_dax__parent_ref + " does not exist");
+    throw std::out_of_range("Parse error on line " + std::to_string(dax_lineno) + ": Asked to add a dependency from " +
+                            current_child->get_name() + " to " + A_dax__parent_ref + ", but " + A_dax__parent_ref +
+                            " does not exist");
   }
 }
 
index 73de1d2..85bf39e 100644 (file)
@@ -312,7 +312,7 @@ void declare_tracing_category(const std::string& name, const std::string& color)
     double blue  = simgrid::xbt::random::uniform_real(0.0, std::nextafter(1.0, 2.0));
     final_color  = std::to_string(red) + " " + std::to_string(green) + " " + std::to_string(blue);
   } else {
-    final_color = std::string(color);
+    final_color = color;
   }
 
   XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", name.c_str(), color.c_str(), final_color.c_str());
index f53a608..5001fc7 100644 (file)
@@ -20,7 +20,7 @@ NetZoneContainer::NetZoneContainer(const std::string& name, unsigned int level,
 {
   xbt_assert(s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Element '%s' not found", get_cname());
   if (parent_) {
-    std::string type_name = std::string("L") + std::to_string(level);
+    std::string type_name = "L" + std::to_string(level);
     type_                 = parent_->type_->by_name_or_create<ContainerType>(type_name);
     parent_->children_.try_emplace(get_name(), this);
     on_creation(*this);
index d5658ef..9d7100e 100644 (file)
@@ -68,7 +68,7 @@ void VariableType::instr_event(double now, double delta, const char* resource, d
   // create a key considering the resource and variable, and check if key exists in the global map:
   // if it doesn't, set the variable to zero.
   if (static std::set<std::string, std::less<>> platform_variables;
-      platform_variables.emplace(std::string(resource) + get_name()).second)
+      platform_variables.emplace(resource + get_name()).second)
     set_event(now, 0);
 
   add_event(now, value);
index b37ed60..5a5ad7a 100644 (file)
@@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_routing, instr, "Tracing platform hierarch
 
 std::string instr_pid(simgrid::s4u::Actor const& proc)
 {
-  return std::string(proc.get_name()) + "-" + std::to_string(proc.get_pid());
+  return proc.get_name() + "-" + std::to_string(proc.get_pid());
 }
 
 static simgrid::instr::Container* lowestCommonAncestor(const simgrid::instr::Container* a1,
@@ -142,10 +142,10 @@ static void recursiveNewVariableType(const std::string& new_typename, const std:
                                      simgrid::instr::Type* root)
 {
   if (root->get_name() == "HOST" || root->get_name() == "VM")
-    root->by_name_or_create(std::string("p") + new_typename, color);
+    root->by_name_or_create("p" + new_typename, color);
 
   if (root->get_name() == "LINK")
-    root->by_name_or_create(std::string("b") + new_typename, color);
+    root->by_name_or_create("b" + new_typename, color);
 
   for (auto const& [_, child] : root->get_children()) {
     recursiveNewVariableType(new_typename, color, child.get());
@@ -501,14 +501,12 @@ void define_callbacks()
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_computing()) {
     s4u::Exec::on_start_cb([](s4u::Exec const& exec) {
-      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
+      Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))
           ->get_state("MPI_STATE")
           ->push_event("computing", new CpuTIData("compute", exec.get_cost()));
     });
     s4u::Activity::on_completion_cb([](const s4u::Activity&) {
-      Container::by_name(std::string("rank-") + std::to_string(s4u::Actor::self()->get_pid()))
-          ->get_state("MPI_STATE")
-          ->pop_event();
+      Container::by_name("rank-" + std::to_string(s4u::Actor::self()->get_pid()))->get_state("MPI_STATE")->pop_event();
     });
   }
 
index 4a41dd0..cd89800 100644 (file)
@@ -68,7 +68,7 @@ static inline std::string contexts_list()
 }
 
 static config::Flag<std::string> context_factory_name("contexts/factory",
-                                                      (std::string("Possible values: ") + contexts_list()).c_str(),
+                                                      ("Possible values: " + contexts_list()).c_str(),
                                                       context_factories.begin()->first);
 
 } // namespace simgrid::kernel
index 6def798..be71dd3 100644 (file)
@@ -66,7 +66,7 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h
     throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.");
   }
 
-  auto* actor = new ActorImpl(std::string(name), host, /*ppid*/ -1);
+  auto* actor = new ActorImpl(name, host, /*ppid*/ -1);
   /* Actor data */
   actor->piface_.set_data(data);
   actor->code_ = nullptr;
@@ -371,8 +371,8 @@ activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout
 activity::ActivityImplPtr ActorImpl::sleep(double duration)
 {
   if (not host_->is_on())
-    throw_exception(std::make_exception_ptr(HostFailureException(
-        XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
+    throw_exception(std::make_exception_ptr(
+        HostFailureException(XBT_THROW_POINT, "Host " + host_->get_name() + " failed, you cannot sleep there.")));
 
   auto sleep_activity = new activity::SleepImpl();
   sleep_activity->set_name("sleep").set_host(host_).set_duration(duration).start();
index ae1d392..1ea0494 100644 (file)
@@ -56,7 +56,7 @@ static std::string to_string_activity_test(const activity::ActivityImpl* act)
   if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
     const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
     const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
-    return std::string("CommTest(comm_id:") + ptr_to_id<activity::CommImpl const>(comm) +
+    return "CommTest(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
            " src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
            " dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
            " mbox:" + std::to_string(comm->get_mailbox_id()) + " srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
@@ -109,10 +109,10 @@ static std::string to_string_activity_wait(const activity::ActivityImpl* act)
   if (auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
     const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
     const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
-    return std::string("CommWait(comm_id:") + ptr_to_id<activity::CommImpl const>(comm) +
+    return "CommWait(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
            " src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
            " dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
-           " mbox:" + std::string(comm->get_mailbox() == nullptr ? std::string("-") : comm->get_mailbox()->get_name()) +
+           " mbox:" + (comm->get_mailbox() == nullptr ? "-" : comm->get_mailbox()->get_name()) +
            "(id:" + std::to_string(comm->get_mailbox_id()) + ") srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
            " bufsize:" + std::to_string(comm->src_buff_size_) + ")";
   } else {
@@ -205,9 +205,9 @@ void CommIsendSimcall::serialize(std::stringstream& stream) const
 }
 std::string CommIsendSimcall::to_string() const
 {
-  return std::string("CommAsyncSend(comm_id: ") + std::to_string((uintptr_t)comm_) +
-         " mbox:" + std::to_string(mbox_->get_id()) + " srcbuf:" + ptr_to_id<unsigned char>(src_buff_) +
-         " bufsize:" + std::to_string(src_buff_size_) + " tag: " + std::to_string(tag_) + ")";
+  return "CommAsyncSend(comm_id: " + std::to_string((uintptr_t)comm_) + " mbox:" + std::to_string(mbox_->get_id()) +
+         " srcbuf:" + ptr_to_id<unsigned char>(src_buff_) + " bufsize:" + std::to_string(src_buff_size_) +
+         " tag: " + std::to_string(tag_) + ")";
 }
 
 void CommIrecvSimcall::serialize(std::stringstream& stream) const
@@ -218,7 +218,7 @@ void CommIrecvSimcall::serialize(std::stringstream& stream) const
 }
 std::string CommIrecvSimcall::to_string() const
 {
-  return std::string("CommAsyncRecv(comm_id: ") + ptr_to_id<activity::CommImpl const>(comm_) +
+  return "CommAsyncRecv(comm_id: " + ptr_to_id<activity::CommImpl const>(comm_) +
          " mbox:" + std::to_string(mbox_->get_id()) + " dstbuf:" + ptr_to_id<unsigned char>(dst_buff_) +
          " tag: " + std::to_string(tag_) + ")";
 }
index 0246d5a..162653d 100644 (file)
@@ -23,7 +23,7 @@ void RandomSimcall::serialize(std::stringstream& stream) const
 }
 std::string RandomSimcall::to_string() const
 {
-  return std::string("Random(min:") + std::to_string(min_) + " max:" + std::to_string(max_) + ")";
+  return "Random(min:" + std::to_string(min_) + " max:" + std::to_string(max_) + ")";
 }
 
 void RandomSimcall::prepare(int times_considered)
@@ -69,7 +69,7 @@ void ActorJoinSimcall::serialize(std::stringstream& stream) const
 }
 std::string ActorJoinSimcall::to_string() const
 {
-  return std::string("ActorJoin(pid:") + std::to_string(other_->get_pid()) + ")";
+  return "ActorJoin(pid:" + std::to_string(other_->get_pid()) + ")";
 }
 
 void ObjectAccessSimcallObserver::serialize(std::stringstream& stream) const
@@ -79,7 +79,7 @@ void ObjectAccessSimcallObserver::serialize(std::stringstream& stream) const
 }
 std::string ObjectAccessSimcallObserver::to_string() const
 {
-  return std::string("ObjectAccess(obj:") + ptr_to_id<ObjectAccessSimcallItem const>(object_) +
+  return "ObjectAccess(obj:" + ptr_to_id<ObjectAccessSimcallItem const>(object_) +
          " owner:" + std::to_string(get_owner()->get_pid()) + ")";
 }
 bool ObjectAccessSimcallObserver::is_visible() const
index 47a129d..d1ecb61 100644 (file)
@@ -57,14 +57,14 @@ void FactorSet::parse(const std::string& values)
         try {
           fact.factor = std::stoi(*factor_iter);
         } catch (const std::invalid_argument&) {
-          throw std::invalid_argument(std::string("Invalid factor in chunk ") + std::to_string(factors_.size() + 1) +
-                                      ": " + *factor_iter + " for " + name_);
+          throw std::invalid_argument("Invalid factor in chunk " + std::to_string(factors_.size() + 1) + ": " +
+                                      *factor_iter + " for " + name_);
         }
       } else {
         try {
           fact.values.push_back(xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, *factor_iter, ""));
         } catch (const std::invalid_argument&) {
-          throw std::invalid_argument(std::string("Invalid factor value ") + std::to_string(iteration) + " in chunk " +
+          throw std::invalid_argument("Invalid factor value " + std::to_string(iteration) + " in chunk " +
                                       std::to_string(factors_.size() + 1) + ": " + *factor_iter + " for " + name_);
         }
       }
index e1370f3..9254c56 100644 (file)
@@ -73,14 +73,14 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top
   try {
     n_groups = std::stoi(tmp[0]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of groups:") + tmp[0]);
+    throw std::invalid_argument("Invalid number of groups:" + tmp[0]);
   }
 
   unsigned int n_blue;
   try {
     n_blue = std::stoi(tmp[1]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of links for the blue level:") + tmp[1]);
+    throw std::invalid_argument("Invalid number of links for the blue level:" + tmp[1]);
   }
 
   // Black network : number of chassis/group, number of links between each router on the black network
@@ -92,14 +92,14 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top
   try {
     n_chassis = std::stoi(tmp[0]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of chassis:") + tmp[0]);
+    throw std::invalid_argument("Invalid number of chassis:" + tmp[0]);
   }
 
   unsigned int n_black;
   try {
     n_black = std::stoi(tmp[1]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of links for the black level:") + tmp[1]);
+    throw std::invalid_argument("Invalid number of links for the black level:" + tmp[1]);
   }
 
   // Green network : number of blades/chassis, number of links between each router on the green network
@@ -111,14 +111,14 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top
   try {
     n_routers = std::stoi(tmp[0]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of routers:") + tmp[0]);
+    throw std::invalid_argument("Invalid number of routers:" + tmp[0]);
   }
 
   unsigned int n_green;
   try {
     n_green = std::stoi(tmp[1]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Invalid number of links for the green level:") + tmp[1]);
+    throw std::invalid_argument("Invalid number of links for the green level:" + tmp[1]);
   }
 
   // The last part of topo_parameters should be the number of nodes per blade
@@ -126,7 +126,7 @@ s4u::DragonflyParams DragonflyZone::parse_topo_parameters(const std::string& top
   try {
     n_nodes = std::stoi(parameters[3]);
   } catch (const std::invalid_argument&) {
-    throw std::invalid_argument(std::string("Last parameter is not the amount of nodes per blade:") + parameters[3]);
+    throw std::invalid_argument("Last parameter is not the amount of nodes per blade:" + parameters[3]);
   }
   return s4u::DragonflyParams({n_groups, n_blue}, {n_chassis, n_black}, {n_routers, n_green}, n_nodes);
 }
index 3c6bfc6..73e8ec7 100644 (file)
@@ -232,9 +232,9 @@ void FatTreeZone::generate_switches(const s4u::ClusterCallbacks& set_callbacks)
     this->nodes_by_level_[0] *= this->num_children_per_node_[i];
 
   if (this->nodes_by_level_[0] != this->nodes_.size()) {
-    surf_parse_error(std::string("The number of provided nodes does not fit with the wanted topology.") +
-                     " Please check your platform description (We need " + std::to_string(this->nodes_by_level_[0]) +
-                     "nodes, we got " + std::to_string(this->nodes_.size()));
+    surf_parse_error("The number of provided nodes does not fit with the wanted topology."
+                     " Please check your platform description (We need " +
+                     std::to_string(this->nodes_by_level_[0]) + "nodes, we got " + std::to_string(this->nodes_.size()));
   }
 
   for (unsigned int i = 0; i < this->levels_; i++) {
@@ -423,12 +423,12 @@ s4u::FatTreeParams FatTreeZone::parse_topo_parameters(const std::string& topo_pa
   try {
     n_lev = std::stoi(parameters[0]);
   } catch (const std::invalid_argument&) {
-    surf_parse_error(std::string("First parameter is not the amount of levels: ") + parameters[0]);
+    surf_parse_error("First parameter is not the amount of levels: " + parameters[0]);
   }
 
   // Then, a l-sized vector standing for the children number by level
   boost::split(tmp, parameters[1], boost::is_any_of(","));
-  surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+  surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
                                              " levels but the child count vector (the first one) contains " +
                                              std::to_string(tmp.size()) + " levels.");
 
@@ -436,33 +436,33 @@ s4u::FatTreeParams FatTreeZone::parse_topo_parameters(const std::string& topo_pa
     try {
       down.push_back(std::stoi(level));
     } catch (const std::invalid_argument&) {
-      surf_parse_error(std::string("Invalid child count: ") + level);
+      surf_parse_error("Invalid child count: " + level);
     }
   }
 
   // Then, a l-sized vector standing for the parents number by level
   boost::split(tmp, parameters[2], boost::is_any_of(","));
-  surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+  surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
                                              " levels but the parent count vector (the second one) contains " +
                                              std::to_string(tmp.size()) + " levels.");
   for (std::string const& parent : tmp) {
     try {
       up.push_back(std::stoi(parent));
     } catch (const std::invalid_argument&) {
-      surf_parse_error(std::string("Invalid parent count: ") + parent);
+      surf_parse_error("Invalid parent count: " + parent);
     }
   }
 
   // Finally, a l-sized vector standing for the ports number with the lower level
   boost::split(tmp, parameters[3], boost::is_any_of(","));
-  surf_parse_assert(tmp.size() == n_lev, std::string("You specified ") + std::to_string(n_lev) +
+  surf_parse_assert(tmp.size() == n_lev, "You specified " + std::to_string(n_lev) +
                                              " levels but the port count vector (the third one) contains " +
                                              std::to_string(tmp.size()) + " levels.");
   for (std::string const& port : tmp) {
     try {
       count.push_back(std::stoi(port));
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid lower level port number:") + port);
+      throw std::invalid_argument("Invalid lower level port number:" + port);
     }
   }
   return s4u::FatTreeParams(n_lev, down, up, count);
index 787bd04..504f682 100644 (file)
@@ -40,10 +40,7 @@ public:
   Channel& channel() { return checker_side_.get_channel(); }
   PageStore& page_store() { return page_store_; }
 
-  std::string const& get_host_name(const char* hostname)
-  {
-    return *this->hostnames_.insert(std::string(hostname)).first;
-  }
+  std::string const& get_host_name(const char* hostname) { return *this->hostnames_.insert(hostname).first; }
 
   void start();
   void shutdown();
index 44ad73e..7b0c0f5 100644 (file)
@@ -510,7 +510,7 @@ static simgrid::mc::Type MC_dwarf_die_to_type(simgrid::mc::ObjectInformation* in
 {
   simgrid::mc::Type type;
   type.type          = dwarf_tag(die);
-  type.name          = std::string();
+  type.name          = "";
   type.element_count = -1;
 
   // Global Offset
@@ -677,7 +677,7 @@ static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::Ob
   }
 
   if (ns && variable->global)
-    variable->name = std::string(ns) + "::" + variable->name;
+    variable->name.insert(0, std::string(ns) + "::");
 
   // The current code needs a variable name,
   // generate a fake one:
index 75a610d..121341a 100644 (file)
@@ -317,7 +317,7 @@ std::string RemoteProcess::read_string(RemotePtr<char> address) const
     xbt_assert(c > 0, "Could not read string from remote process");
 
     if (memchr(res.data() + off, '\0', c))
-      return std::string(res.data());
+      return res.data();
 
     off += c;
     if (off == (off_t)res.size())
index b36d8cd..01ae368 100644 (file)
@@ -130,7 +130,7 @@ static std::vector<s_mc_stack_frame_t> unwind_stack_frames(UnwindContext* stack_
       stack_frame.frame_base = (unw_word_t)frame->frame_base(c);
     } else {
       stack_frame.frame_base = 0;
-      stack_frame.frame_name = std::string();
+      stack_frame.frame_name = "";
     }
 
     result.push_back(std::move(stack_frame));
index 2579f3b..c2bf802 100644 (file)
@@ -57,7 +57,7 @@ public:
   void set_not_used() { this->is_used_ = false; }
   const std::string& get_name() const { return name_; }
   const char* get_cname() const { return name_.c_str(); }
-  void set_name(const char* new_name) { name_ = std::string(new_name); }
+  void set_name(const char* new_name) { name_ = new_name; }
   void set_tracing_category(const char* category) { tracing_category_ = category ? category : ""; }
   const std::string& get_tracing_category() const { return tracing_category_; }
   bool has_tracing_category() { return not tracing_category_.empty(); }
index 146845c..122b506 100644 (file)
@@ -103,7 +103,7 @@ s4u::CommPtr Task::send_async(const std::string& alias, void_f_pvoid_t cleanup,
 {
   if (TRACE_actor_is_enabled()) {
     auto* process_container       = instr::Container::by_name(instr_pid(*MSG_process_self()));
-    std::string key               = std::string("p") + std::to_string(get_id());
+    std::string key               = "p" + std::to_string(get_id());
     instr::Container::get_root()->get_link("ACTOR_LINK")->start_event(process_container, "SR", key);
   }
 
@@ -574,7 +574,7 @@ msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char*
   if (TRACE_actor_is_enabled() && ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
     auto* process_container = simgrid::instr::Container::by_name(instr_pid(*MSG_process_self()));
 
-    std::string key = std::string("p") + std::to_string((*task)->get_id());
+    std::string key = "p" + std::to_string((*task)->get_id());
     simgrid::instr::Container::get_root()->get_link("ACTOR_LINK")->end_event(process_container, "SR", key);
   }
   return ret;
index 1a7cccc..31f743a 100644 (file)
@@ -58,7 +58,7 @@ const Disk* File::find_local_disk_on(const Host* host)
                host->get_cname());
     /* Mount point found, split fullpath_ into mount_name and path+filename*/
     mount_point_ = fullpath_.substr(0, longest_prefix_length);
-    if (mount_point_ == std::string("/"))
+    if (mount_point_ == "/")
       path_ = fullpath_;
     else
       path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
@@ -307,7 +307,7 @@ int File::remote_copy(sg_host_t host, const std::string& fullpath)
 
   for (auto const& disk : host->get_disks()) {
     std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
-    std::string mount_point   = std::string(fullpath).substr(0, current_mount.length());
+    std::string mount_point   = fullpath.substr(0, current_mount.length());
     if (mount_point == current_mount && current_mount.length() > longest_prefix_length) {
       /* The current mount name is found in the full path and is bigger than the previous*/
       longest_prefix_length = current_mount.length();
@@ -348,9 +348,9 @@ FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
   }
 
   if (const char* current_mount_str = ptr->get_property("mount"))
-    mount_point_ = std::string(current_mount_str);
+    mount_point_ = current_mount_str;
   else
-    mount_point_ = std::string("/");
+    mount_point_ = "/";
 
   if (const char* content_str = ptr->get_property("content"))
     content_.reset(parse_content(content_str));
index 9245029..2728cce 100644 (file)
@@ -366,7 +366,7 @@ static void on_host_added(simgrid::s4u::Host& host)
   if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
     return;
 
-  std::string name              = std::string("dvfs-daemon-") + host.get_cname();
+  std::string name              = "dvfs-daemon-" + host.get_name();
   simgrid::s4u::ActorPtr daemon = simgrid::s4u::Actor::create(name.c_str(), &host, []() {
     /**
      * This lambda function is the function the actor (daemon) will execute
@@ -379,7 +379,7 @@ static void on_host_added(simgrid::s4u::Host& host)
 
     std::string dvfs_governor;
     if (const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor")) {
-      dvfs_governor = std::string(host_conf);
+      dvfs_governor = host_conf;
       boost::algorithm::to_lower(dvfs_governor);
     } else {
       dvfs_governor = cfg_governor;
index 6d9483d..abb4fcd 100644 (file)
@@ -216,10 +216,10 @@ HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr)
   const char* off_power_str = host_->get_property("wattage_off");
   if (off_power_str != nullptr) {
     try {
-      this->watts_off_ = std::stod(std::string(off_power_str));
+      this->watts_off_ = std::stod(off_power_str);
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid value for property wattage_off of host ") + host_->get_cname() +
-                                  ": " + off_power_str);
+      throw std::invalid_argument("Invalid value for property wattage_off of host " + host_->get_name() + ": " +
+                                  off_power_str);
     }
   }
   /* watts_off is 0 by default */
index 51bd89c..0c2a3ac 100644 (file)
@@ -110,13 +110,13 @@ void LinkEnergy::init_watts_range_list()
     try {
       idle_ = std::stod(current_power_values.front());
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+      throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
     }
 
     try {
       busy_ = std::stod(current_power_values.back());
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
+      throw std::invalid_argument("Invalid busy power value for link " + this->link_->get_name());
     }
   }
 }
index 5b46eb9..8bfead7 100644 (file)
@@ -214,7 +214,7 @@ void LinkEnergyWifi::init_watts_range_list()
     try {
       control_duration_ = std::stod(beacons_factor);
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid beacons factor value for link ") + this->link_->get_cname());
+      throw std::invalid_argument("Invalid beacons factor value for link " + this->link_->get_name());
     }
   }
 
@@ -237,22 +237,22 @@ void LinkEnergyWifi::init_watts_range_list()
       try {
         pSleep_ = std::stod(current_power_values.at(3));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pRx_ = std::stod(current_power_values.at(2));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pTx_ = std::stod(current_power_values.at(1));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pIdle_ = std::stod(current_power_values.at(0));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid busy power value for link " + this->link_->get_name());
       }
 
       XBT_DEBUG("Values aa initialized with: pSleep=%f pIdle=%f pTx=%f pRx=%f", pSleep_, pIdle_, pTx_, pRx_);
index 192c4b2..75f3a02 100644 (file)
@@ -27,7 +27,7 @@ void MigrationRx::operator()()
   bool received_finalize = false;
 
   std::string finalize_task_name =
-      std::string("__mig_stage3:") + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
+      "__mig_stage3:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")";
 
   while (not received_finalize) {
     auto payload = mbox->get_unique<std::string>();
@@ -72,7 +72,7 @@ void MigrationRx::operator()()
   }
   // Inform the SRC that the migration has been correctly performed
   auto* payload = new std::string("__mig_stage4:");
-  *payload      = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")";
+  *payload      = *payload + vm_->get_name() + "(" + src_pm_->get_name() + "-" + dst_pm_->get_name() + ")";
 
   mbox_ctl->put(payload, 0);
 
@@ -333,10 +333,8 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
 
   vm->start_migration();
 
-  std::string rx_name =
-      std::string("__pr_mig_rx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")";
-  std::string tx_name =
-      std::string("__pr_mig_tx:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")";
+  std::string rx_name = "__pr_mig_rx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")";
+  std::string tx_name = "__pr_mig_tx:" + vm->get_name() + "(" + src_pm->get_name() + "-" + dst_pm->get_name() + ")";
 
   simgrid::s4u::ActorPtr rx =
       simgrid::s4u::Actor::create(rx_name.c_str(), dst_pm, simgrid::plugin::vm::MigrationRx(vm, dst_pm));
@@ -347,8 +345,8 @@ void sg_vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
 
   /* wait until the migration have finished or on error has occurred */
   XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed");
-  simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name(
-      std::string("__mbox_mig_ctl:") + vm->get_cname() + "(" + src_pm->get_cname() + "-" + dst_pm->get_cname() + ")");
+  simgrid::s4u::Mailbox* mbox_ctl = simgrid::s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm->get_name() + "(" +
+                                                                   src_pm->get_name() + "-" + dst_pm->get_name() + ")");
   mbox_ctl->get_unique<std::string>();
   tx->join();
   rx->join();
index 26ed66c..c7880a3 100644 (file)
@@ -38,10 +38,10 @@ public:
   {
     src_pm_ = vm_->get_pm();
 
-    mbox_ctl = s4u::Mailbox::by_name(std::string("__mbox_mig_ctl:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
-                                     "-" + dst_pm_->get_cname() + ")");
-    mbox = s4u::Mailbox::by_name(std::string("__mbox_mig_src_dst:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
-                                 "-" + dst_pm_->get_cname() + ")");
+    mbox_ctl = s4u::Mailbox::by_name("__mbox_mig_ctl:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+                                     dst_pm_->get_name() + ")");
+    mbox     = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+                                 dst_pm_->get_name() + ")");
   }
   void operator()();
 };
@@ -57,8 +57,8 @@ public:
   explicit MigrationTx(s4u::VirtualMachine* vm, s4u::Host* dst_pm) : vm_(vm), dst_pm_(dst_pm)
   {
     src_pm_ = vm_->get_pm();
-    mbox    = s4u::Mailbox::by_name(std::string("__mbox_mig_src_dst:") + vm_->get_cname() + "(" + src_pm_->get_cname() +
-                                 "-" + dst_pm_->get_cname() + ")");
+    mbox    = s4u::Mailbox::by_name("__mbox_mig_src_dst:" + vm_->get_name() + "(" + src_pm_->get_name() + "-" +
+                                 dst_pm_->get_name() + ")");
   }
   void operator()();
   sg_size_t sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout);
index 8da467d..5e5b04a 100644 (file)
@@ -208,7 +208,7 @@ Host* Engine::host_by_name(const std::string& name) const
 {
   auto* host = host_by_name_or_null(name);
   if (not host)
-    throw std::invalid_argument(std::string("Host not found: '") + name + std::string("'"));
+    throw std::invalid_argument("Host not found: '" + name + "'");
   return host;
 }
 
@@ -232,7 +232,7 @@ Link* Engine::link_by_name(const std::string& name) const
 {
   auto* link = link_by_name_or_null(name);
   if (not link)
-    throw std::invalid_argument(std::string("Link not found: ") + name);
+    throw std::invalid_argument("Link not found: " + name);
   return link;
 }
 
@@ -240,7 +240,7 @@ SplitDuplexLink* Engine::split_duplex_link_by_name(const std::string& name) cons
 {
   auto* link_impl = pimpl->netzone_root_ ? pimpl->netzone_root_->get_split_duplex_link_by_name_or_null(name) : nullptr;
   if (not link_impl)
-    throw std::invalid_argument(std::string("Link not found: ") + name);
+    throw std::invalid_argument("Link not found: " + name);
   return link_impl->get_iface();
 }
 
@@ -396,7 +396,7 @@ kernel::routing::NetPoint* Engine::netpoint_by_name(const std::string& name) con
 {
   auto netp = netpoint_by_name_or_null(name);
   if (netp == nullptr) {
-    throw std::invalid_argument(std::string("Netpoint not found: %s") + name);
+    throw std::invalid_argument("Netpoint not found: " + name);
   }
   return netp;
 }
index 6f80d6e..8a6cc71 100644 (file)
@@ -283,7 +283,7 @@ std::vector<double> Host::convert_pstate_speed_vector(const std::vector<std::str
       double speed = xbt_parse_get_speed("", 0, speed_str, "");
       speed_list.push_back(speed);
     } catch (const simgrid::ParseError&) {
-      throw std::invalid_argument(std::string("Invalid speed value: ") + speed_str);
+      throw std::invalid_argument("Invalid speed value: " + speed_str);
     }
   }
   return speed_list;
@@ -340,15 +340,13 @@ Disk* Host::create_disk(const std::string& name, const std::string& read_bandwid
   try {
     d_read = xbt_parse_get_bandwidth("", 0, read_bandwidth, "");
   } catch (const simgrid::ParseError&) {
-    throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
-                                std::string(". Invalid read bandwidth: ") + read_bandwidth);
+    throw std::invalid_argument("Impossible to create disk: " + name + ". Invalid read bandwidth: " + read_bandwidth);
   }
   double d_write;
   try {
     d_write = xbt_parse_get_bandwidth("", 0, write_bandwidth, "");
   } catch (const simgrid::ParseError&) {
-    throw std::invalid_argument(std::string("Impossible to create disk: ") + name +
-                                std::string(". Invalid write bandwidth: ") + write_bandwidth);
+    throw std::invalid_argument("Impossible to create disk: " + name + ". Invalid write bandwidth: " + write_bandwidth);
   }
   return create_disk(name, d_read, d_write);
 }
index a35cd13..1e1e5eb 100644 (file)
@@ -82,8 +82,7 @@ Link* Link::set_latency(const std::string& value)
   try {
     d_value = xbt_parse_get_time("", 0, value, "");
   } catch (const simgrid::ParseError&) {
-    throw std::invalid_argument(std::string("Impossible to set latency for link: ") + get_name() +
-                                std::string(". Invalid value: ") + value);
+    throw std::invalid_argument("Impossible to set latency for link: " + get_name() + ". Invalid value: " + value);
   }
   return set_latency(d_value);
 }
@@ -102,8 +101,8 @@ Link* Link::set_bandwidth(double value)
 Link* Link::set_sharing_policy(Link::SharingPolicy policy, const NonLinearResourceCb& cb)
 {
   if (policy == SharingPolicy::SPLITDUPLEX || policy == SharingPolicy::WIFI)
-    throw std::invalid_argument(std::string("Impossible to set wifi or split-duplex for the link: ") + get_name() +
-                                std::string(". Use appropriate create function in NetZone."));
+    throw std::invalid_argument("Impossible to set wifi or split-duplex for the link: " + get_name() +
+                                ". Use appropriate create function in NetZone.");
 
   kernel::actor::simcall_object_access(pimpl_, [this, policy, &cb] { pimpl_->set_sharing_policy(policy, cb); });
   return this;
index 388cdd4..180eacd 100644 (file)
@@ -170,8 +170,8 @@ s4u::SplitDuplexLink* NetZone::create_split_duplex_link(const std::string& name,
   try {
     speed = xbt_parse_get_bandwidth("", 0, bandwidth, "");
   } catch (const simgrid::ParseError&) {
-    throw std::invalid_argument(std::string("Impossible to create split-duplex link: ") + name +
-                                std::string(". Invalid bandwidth: ") + bandwidth);
+    throw std::invalid_argument("Impossible to create split-duplex link: " + name +
+                                ". Invalid bandwidth: " + bandwidth);
   }
   return create_split_duplex_link(name, speed);
 }
@@ -191,8 +191,7 @@ s4u::Link* NetZone::create_link(const std::string& name, const std::vector<std::
       double speed = xbt_parse_get_bandwidth("", 0, speed_str, "");
       bw.push_back(speed);
     } catch (const simgrid::ParseError&) {
-      throw std::invalid_argument(std::string("Impossible to create link: ") + name +
-                                  std::string(". Invalid bandwidth: ") + speed_str);
+      throw std::invalid_argument("Impossible to create link: " + name + ". Invalid bandwidth: " + speed_str);
     }
   }
   return create_link(name, bw);
index 46b643e..24f158f 100644 (file)
@@ -81,7 +81,7 @@ void VirtualMachine::destroy()
 
   if (not this_actor::is_maestro() && this_actor::get_host() == this) {
     XBT_VERB("Launch another actor on physical host %s to destroy my own VM: %s", get_pm()->get_cname(), get_cname());
-    simgrid::s4u::Actor::create(get_cname() + std::string("-vm_destroy"), get_pm(), destroy_code);
+    simgrid::s4u::Actor::create(get_name() + "-vm_destroy", get_pm(), destroy_code);
     simgrid::s4u::this_actor::yield();
     XBT_CRITICAL("I should be dead now!");
     DIE_IMPOSSIBLE;
index 543f451..684b283 100644 (file)
@@ -188,7 +188,7 @@ MPI_Aint PMPI_Aint_diff(MPI_Aint address, MPI_Aint disp)
 int PMPI_Get_processor_name(char *name, int *resultlen)
 {
   int len = std::min(static_cast<int>(sg_host_self()->get_name().size()), MPI_MAX_PROCESSOR_NAME - 1);
-  std::string(sg_host_self()->get_name()).copy(name, len);
+  sg_host_self()->get_name().copy(name, len);
   name[len]  = '\0';
   *resultlen = len;
 
index 1804c73..f83a8d3 100644 (file)
@@ -121,7 +121,7 @@ int PMPI_Igather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void
   }
   CHECK_ROOT(7)
   CHECK_REQUEST(9)
-  CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather") + +" with root " +
+  CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather") + " with root " +
                              std::to_string(root))
 
   const void* real_sendbuf   = sendbuf;
index 01c108c..688e330 100644 (file)
@@ -28,7 +28,7 @@
             simgrid::instr::Container::get_root()->get_type()->by_name_or_create<simgrid::instr::EventType>(           \
                 _XBT_STRINGIFY(cat));                                                                                  \
                                                                                                                        \
-        std::string cont_name = std::string("rank-" + std::to_string(simgrid::s4u::this_actor::get_pid()));            \
+        std::string cont_name = "rank-" + std::to_string(simgrid::s4u::this_actor::get_pid());                         \
         type->add_entity_value(desc->name, "1.0 1.0 1.0");                                                             \
         new simgrid::instr::NewEvent(simgrid::s4u::Engine::get_clock(), simgrid::instr::Container::by_name(cont_name), \
                                      type, type->get_entity_value(desc->name));                                        \
index 3d704cd..973dd0b 100644 (file)
@@ -20,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI colle
 namespace simgrid::smpi {
 
 std::map<std::string, std::vector<s_mpi_coll_description_t>, std::less<>> smpi_coll_descriptions(
-    {{std::string("gather"),
+    {{"gather",
       {{"default", "gather default collective", (void*)gather__default},
        {"ompi", "gather ompi collective", (void*)gather__ompi},
        {"ompi_basic_linear", "gather ompi_basic_linear collective", (void*)gather__ompi_basic_linear},
index a2e404e..fbf6a29 100644 (file)
@@ -128,7 +128,7 @@ public:
   Datatype(const Datatype&) = delete;
   Datatype& operator=(const Datatype&) = delete;
   ~Datatype() override;
-  std::string name() const override {return name_.empty() ? std::string("MPI_Datatype") : name_;}
+  std::string name() const override { return name_.empty() ? "MPI_Datatype" : name_; }
   size_t size() const { return size_; }
   MPI_Aint lb() const { return lb_; }
   MPI_Aint ub() const { return ub_; }
index 60ab2fd..631d5cd 100644 (file)
@@ -44,7 +44,7 @@ class File : public F2C{
   int flags() const;
   MPI_Datatype etype() const;
   MPI_Comm comm() const;
-  std::string name() const override {return file_ ? std::string("MPI_File: ")+ std::string(file_->get_path()): std::string("MPI_File");}
+  std::string name() const override { return file_ ? "MPI_File: " + std::string(file_->get_path()) : "MPI_File"; }
 
   int sync();
   int seek(MPI_Offset offset, int whence);
index aed599b..ed3cea6 100644 (file)
@@ -34,7 +34,7 @@ public:
   void set_mapping(aid_t pid, int rank);
   int rank(aid_t pid) const;
   aid_t actor(int rank) const;
-  std::string name() const override {return std::string("MPI_Group");}
+  std::string name() const override { return "MPI_Group"; }
   void ref();
   static void unref(MPI_Group group);
   int size() const { return static_cast<int>(rank_to_pid_map_.size()); }
index d406801..c3d8e4d 100644 (file)
@@ -25,7 +25,7 @@ public:
   static void unref(MPI_Info info);
   void set(const char* key, const char* value) { map_[key] = value; }
   int get(const char* key, int valuelen, char* value, int* flag) const;
-  std::string name() const override {return std::string("MPI_Info");}
+  std::string name() const override { return "MPI_Info"; }
   int remove(const char* key);
   int get_nkeys(int* nkeys) const;
   int get_nthkey(int n, char* key) const;
index d63ed7b..ba3292d 100644 (file)
@@ -67,7 +67,7 @@ public:
   int tag() const { return tag_; }
   int flags() const { return flags_; }
   bool detached() const { return detached_; }
-  std::string name() const override { return std::string("MPI_Request"); }
+  std::string name() const override { return "MPI_Request"; }
   MPI_Datatype type() const { return type_; }
   void print_request(const char* message) const;
   void start();
index ea8b9c4..6bcab2d 100644 (file)
@@ -56,7 +56,7 @@ public:
   int attach (void *base, MPI_Aint size);
   int detach (const void *base);
   void get_name(char* name, int* length) const;
-  std::string name() const override {return name_.empty() ? std::string("MPI_Win") : name_;}
+  std::string name() const override { return name_.empty() ? "MPI_Win" : name_; }
   void get_group( MPI_Group* group);
   void set_name(const char* name);
   int rank() const;
index 335b79e..ea982cd 100644 (file)
@@ -96,7 +96,7 @@ static const char* instr_find_color(const char* c_state)
 
 XBT_PRIVATE simgrid::instr::Container* smpi_container(aid_t pid)
 {
-  return simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(pid));
+  return simgrid::instr::Container::by_name("rank-" + std::to_string(pid));
 }
 
 static std::string TRACE_smpi_put_key(aid_t src, aid_t dst, int tag, int send)
@@ -139,7 +139,7 @@ void TRACE_smpi_setup_container(aid_t pid, const_sg_host_t host)
     parent = simgrid::instr::Container::by_name_or_null(host->get_name());
     xbt_assert(parent != nullptr, "Could not find a parent for mpi rank 'rank-%ld' at function %s", pid, __func__);
   }
-  parent->create_child(std::string("rank-") + std::to_string(pid), "MPI"); // This container is of type MPI
+  parent->create_child("rank-" + std::to_string(pid), "MPI"); // This container is of type MPI
 }
 
 void TRACE_smpi_init(aid_t pid, const std::string& calling_func)
index 68570b3..c192392 100644 (file)
@@ -186,7 +186,7 @@ void SleepParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
 void LocationParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
 {
   CHECK_ACTION_PARAMS(action, 2, 0)
-  filename = std::string(action[2]);
+  filename = action[2];
   line = std::stoi(action[3]);
 }
 
index 2aab0ff..0f84820 100644 (file)
@@ -185,9 +185,9 @@ std::string Comm::name() const
   std::array<char, MPI_MAX_NAME_STRING + 1> name;
   this->get_name(name.data(), &size);
   if (name[0]=='\0')
-    return std::string("MPI_Comm");
+    return "MPI_Comm";
   else
-    return std::string(name.data());
+    return name.data();
 }
 
 
index 2b77328..98f7ccf 100644 (file)
@@ -282,7 +282,7 @@ int File::set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, c
 {
   etype_    = etype;
   filetype_ = filetype;
-  datarep_  = std::string(datarep);
+  datarep_  = datarep;
   disp_     = disp;
   if (comm_->rank() == 0){
     if(disp != MPI_DISPLACEMENT_CURRENT)
index d646288..7b7175d 100644 (file)
@@ -40,7 +40,7 @@ HostImpl::~HostImpl()
     try {
       std::string actors;
       for (auto const& actor : actor_list_)
-        actors += "\n\t" + std::string(actor.get_name());
+        actors += "\n\t" + actor.get_name();
 
       EngineImpl::get_instance()->display_all_actor_status();
       xbt_die("%s:%s", msg, actors.c_str());
index f7f4837..d78115a 100644 (file)
@@ -149,7 +149,7 @@ sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs
              "(total = %zu). Check the 'radical' parameter in XML",
              cluster->id.c_str(), id, cluster->radicals.size());
 
-  std::string host_id = std::string(cluster->prefix) + std::to_string(cluster->radicals[id]) + cluster->suffix;
+  std::string host_id = cluster->prefix + std::to_string(cluster->radicals[id]) + cluster->suffix;
   XBT_DEBUG("Cluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front());
   const simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds)
                                        ->set_core_count(cluster->core_amount)
@@ -170,7 +170,7 @@ sg_platf_cluster_create_loopback(const simgrid::kernel::routing::ClusterCreation
              "(total = %zu). Check the 'radical' parameter in XML",
              cluster->id.c_str(), id, cluster->radicals.size());
 
-  std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(cluster->radicals[id]) + "_loopback";
+  std::string link_id = cluster->id + "_link_" + std::to_string(cluster->radicals[id]) + "_loopback";
   XBT_DEBUG("Cluster: creating loopback link=%s bw=%f", link_id.c_str(), cluster->loopback_bw);
 
   simgrid::s4u::Link* loopback = zone->create_link(link_id, cluster->loopback_bw)
@@ -186,7 +186,7 @@ static simgrid::s4u::Link* sg_platf_cluster_create_limiter(const simgrid::kernel
                                                            const std::vector<unsigned long>& /*coord*/,
                                                            unsigned long id)
 {
-  std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_limiter";
+  std::string link_id = cluster->id + "_link_" + std::to_string(id) + "_limiter";
   XBT_DEBUG("Cluster: creating limiter link=%s bw=%f", link_id.c_str(), cluster->limiter_link);
 
   simgrid::s4u::Link* limiter = zone->create_link(link_id, cluster->limiter_link)->seal();
@@ -250,7 +250,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
   /* Make the backbone */
   const simgrid::s4u::Link* backbone = nullptr;
   if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
-    std::string bb_name = std::string(cluster->id) + "_backbone";
+    std::string bb_name = cluster->id + "_backbone";
     XBT_DEBUG("<link\tid=\"%s\" bw=\"%f\" lat=\"%f\"/> <!--backbone -->", bb_name.c_str(), cluster->bb_bw,
               cluster->bb_lat);
 
@@ -261,7 +261,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
   }
 
   for (int const& i : cluster->radicals) {
-    std::string host_id = std::string(cluster->prefix) + std::to_string(i) + cluster->suffix;
+    std::string host_id = cluster->prefix + std::to_string(i) + cluster->suffix;
 
     XBT_DEBUG("<host\tid=\"%s\"\tspeed=\"%f\">", host_id.c_str(), cluster->speeds.front());
     const auto* host = zone->create_host(host_id, cluster->speeds)
@@ -271,7 +271,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
 
     XBT_DEBUG("</host>");
 
-    std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(i);
+    std::string link_id = cluster->id + "_link_" + std::to_string(i);
     XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id.c_str(), cluster->bw, cluster->lat);
 
     // add a loopback link
@@ -291,7 +291,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
     // add a limiter link (shared link to account for maximal bandwidth of the node)
     const simgrid::s4u::Link* limiter = nullptr;
     if (cluster->limiter_link > 0) {
-      std::string limiter_name = std::string(link_id) + "_limiter";
+      std::string limiter_name = link_id + "_limiter";
       XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", limiter_name.c_str(), cluster->limiter_link);
 
       limiter = zone->create_link(limiter_name, cluster->limiter_link)->seal();
@@ -320,7 +320,7 @@ static void sg_platf_new_cluster_flat(simgrid::kernel::routing::ClusterCreationA
   XBT_DEBUG(" ");
   XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id.c_str());
   if (cluster->router_id.empty())
-    cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
+    cluster->router_id = cluster->prefix + cluster->id + "_router" + cluster->suffix;
   auto* router = zone->create_router(cluster->router_id);
   zone->add_route(router, nullptr, nullptr, nullptr, {});
 
index a46d4ac..300bc16 100644 (file)
@@ -26,7 +26,7 @@ XBT_PRIVATE std::unordered_map<std::string, std::string> trace_connect_list_link
 void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs* trace_connect)
 {
   surf_parse_assert(traces_set_list.find(trace_connect->trace) != traces_set_list.end(),
-                    std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element +
+                    "Cannot connect trace " + trace_connect->trace + " to " + trace_connect->element +
                         ": trace unknown");
 
   switch (trace_connect->kind) {
@@ -46,7 +46,7 @@ void sg_platf_trace_connect(simgrid::kernel::routing::TraceConnectCreationArgs*
       trace_connect_list_link_lat.try_emplace(trace_connect->trace, trace_connect->element);
       break;
     default:
-      surf_parse_error(std::string("Cannot connect trace ") + trace_connect->trace + " to " + trace_connect->element +
+      surf_parse_error("Cannot connect trace " + trace_connect->trace + " to " + trace_connect->element +
                        ": unknown kind of trace");
   }
 }
@@ -68,51 +68,51 @@ void parse_platform_file(const std::string& file)
   /* connect all profiles relative to hosts */
   for (auto const& [trace, name] : trace_connect_list_host_avail) {
     surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
-                      std::string("<trace_connect kind=\"HOST_AVAIL\">: Trace ") + trace + " undefined.");
+                      "<trace_connect kind=\"HOST_AVAIL\">: Trace " + trace + " undefined.");
     auto profile = traces_set_list.at(trace);
 
     auto host = engine->host_by_name_or_null(name);
-    surf_parse_assert(host, std::string("<trace_connect kind=\"HOST_AVAIL\">: Host ") + name + " undefined.");
+    surf_parse_assert(host, "<trace_connect kind=\"HOST_AVAIL\">: Host " + name + " undefined.");
     host->set_state_profile(profile);
   }
 
   for (auto const& [trace, name] : trace_connect_list_host_speed) {
     surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
-                      std::string("<trace_connect kind=\"SPEED\">: Trace ") + trace + " undefined.");
+                      "<trace_connect kind=\"SPEED\">: Trace " + trace + " undefined.");
     auto profile = traces_set_list.at(trace);
 
     auto host = engine->host_by_name_or_null(name);
-    surf_parse_assert(host, std::string("<trace_connect kind=\"SPEED\">: Host ") + name + " undefined.");
+    surf_parse_assert(host, "<trace_connect kind=\"SPEED\">: Host " + name + " undefined.");
     host->set_speed_profile(profile);
   }
 
   for (auto const& [trace, name] : trace_connect_list_link_avail) {
     surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
-                      std::string("<trace_connect kind=\"LINK_AVAIL\">: Trace ") + trace + " undefined.");
+                      "<trace_connect kind=\"LINK_AVAIL\">: Trace " + trace + " undefined.");
     auto profile = traces_set_list.at(trace);
 
     auto link = engine->link_by_name_or_null(name);
-    surf_parse_assert(link, std::string("<trace_connect kind=\"LINK_AVAIL\">: Link ") + name + " undefined.");
+    surf_parse_assert(link, "<trace_connect kind=\"LINK_AVAIL\">: Link " + name + " undefined.");
     link->set_state_profile(profile);
   }
 
   for (auto const& [trace, name] : trace_connect_list_link_bw) {
     surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
-                      std::string("<trace_connect kind=\"BANDWIDTH\">: Trace ") + trace + " undefined.");
+                      "<trace_connect kind=\"BANDWIDTH\">: Trace " + trace + " undefined.");
     auto profile = traces_set_list.at(trace);
 
     auto link = engine->link_by_name_or_null(name);
-    surf_parse_assert(link, std::string("<trace_connect kind=\"BANDWIDTH\">: Link ") + name + " undefined.");
+    surf_parse_assert(link, "<trace_connect kind=\"BANDWIDTH\">: Link " + name + " undefined.");
     link->set_bandwidth_profile(profile);
   }
 
   for (auto const& [trace, name] : trace_connect_list_link_lat) {
     surf_parse_assert(traces_set_list.find(trace) != traces_set_list.end(),
-                      std::string("<trace_connect kind=\"LATENCY\">: Trace ") + trace + " undefined.");
+                      "<trace_connect kind=\"LATENCY\">: Trace " + trace + " undefined.");
     auto profile = traces_set_list.at(trace);
 
     auto link = engine->link_by_name_or_null(name);
-    surf_parse_assert(link, std::string("<trace_connect kind=\"LATENCY\">: Link ") + name + " undefined.");
+    surf_parse_assert(link, "<trace_connect kind=\"LATENCY\">: Link " + name + " undefined.");
     link->set_latency_profile(profile);
   }
 
index 7d42393..93f87d0 100644 (file)
@@ -112,7 +112,7 @@ static void explodesRadical(const std::string& radicals, std::vector<int>* explo
         end = surf_parse_get_int(radical_ends.back());
         break;
       default:
-        surf_parse_error(std::string("Malformed radical: ") + group);
+        surf_parse_error("Malformed radical: " + group);
     }
     for (int i = start; i <= end; i++)
       exploded->push_back(i);
@@ -198,7 +198,7 @@ void STag_surfxml_platform() {
                                      "available in the tools/ directory of the source archive.");
   surf_parse_assert(
       version >= 400L,
-      std::string("******* THIS FILE IS TOO OLD (v:") + version_string +
+      "******* THIS FILE IS TOO OLD (v:" + version_string +
           ") *********\n "
           "Changes introduced in SimGrid 3.13:\n"
           "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
@@ -217,7 +217,7 @@ void STag_surfxml_platform() {
              "available in the tools/ directory of the source archive.",
              version_string.c_str(), surf_parsed_filename.c_str());
   }
-  surf_parse_assert(version <= 410L, std::string("******* THIS FILE COMES FROM THE FUTURE (v:") + version_string +
+  surf_parse_assert(version <= 410L, "******* THIS FILE COMES FROM THE FUTURE (v:" + version_string +
                                          ") *********\n "
                                          "The most recent formalism that this version of SimGrid understands is v4.1.\n"
                                          "Please update your code, or use another, more adapted, file.");
@@ -348,7 +348,7 @@ void ETag_surfxml_cluster(){
     cluster.topology = simgrid::kernel::routing::ClusterTopology::DRAGONFLY;
     break;
   default:
-    surf_parse_error(std::string("Invalid cluster topology for cluster ") + cluster.id);
+    surf_parse_error("Invalid cluster topology for cluster " + cluster.id);
   }
   cluster.topo_parameters = A_surfxml_cluster_topo___parameters;
   cluster.router_id = A_surfxml_cluster_router___id;
@@ -368,7 +368,7 @@ void ETag_surfxml_cluster(){
     cluster.sharing_policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
     break;
   default:
-    surf_parse_error(std::string("Invalid cluster sharing policy for cluster ") + cluster.id);
+    surf_parse_error("Invalid cluster sharing policy for cluster " + cluster.id);
   }
   switch (AX_surfxml_cluster_bb___sharing___policy) {
   case A_surfxml_cluster_bb___sharing___policy_FATPIPE:
@@ -378,7 +378,7 @@ void ETag_surfxml_cluster(){
     cluster.bb_sharing_policy = simgrid::s4u::Link::SharingPolicy::SHARED;
     break;
   default:
-    surf_parse_error(std::string("Invalid bb sharing policy in cluster ") + cluster.id);
+    surf_parse_error("Invalid bb sharing policy in cluster " + cluster.id);
   }
 
   sg_platf_new_tag_cluster(&cluster);
@@ -407,7 +407,7 @@ void STag_surfxml_cabinet(){
 void STag_surfxml_peer(){
   simgrid::kernel::routing::PeerCreationArgs peer;
 
-  peer.id          = std::string(A_surfxml_peer_id);
+  peer.id = A_surfxml_peer_id;
   peer.speed =
       xbt_parse_get_speed(surf_parsed_filename, surf_parse_lineno, A_surfxml_peer_speed, "speed of peer " + peer.id);
   peer.bw_in = xbt_parse_get_bandwidth(surf_parsed_filename, surf_parse_lineno, A_surfxml_peer_bw___in,
@@ -443,7 +443,7 @@ void ETag_surfxml_link(){
   link.properties = property_sets.back();
   property_sets.pop_back();
 
-  link.id                  = std::string(A_surfxml_link_id);
+  link.id                  = A_surfxml_link_id;
   link.bandwidths          = xbt_parse_get_bandwidths(surf_parsed_filename, surf_parse_lineno, A_surfxml_link_bandwidth,
                                              "bandwidth of link " + link.id);
   link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0]
@@ -476,7 +476,7 @@ void ETag_surfxml_link(){
     link.policy = simgrid::s4u::Link::SharingPolicy::WIFI;
     break;
   default:
-    surf_parse_error(std::string("Invalid sharing policy in link ") + link.id);
+    surf_parse_error("Invalid sharing policy in link " + link.id);
   }
 
   sg_platf_new_link(&link);
@@ -490,14 +490,14 @@ void STag_surfxml_link___ctn()
   switch (A_surfxml_link___ctn_direction) {
   case AU_surfxml_link___ctn_direction:
   case A_surfxml_link___ctn_direction_NONE:
-    link = engine->link_by_name(std::string(A_surfxml_link___ctn_id));
+    link = engine->link_by_name(A_surfxml_link___ctn_id);
     break;
   case A_surfxml_link___ctn_direction_UP:
-    link      = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
+    link      = engine->split_duplex_link_by_name(A_surfxml_link___ctn_id);
     direction = simgrid::s4u::LinkInRoute::Direction::UP;
     break;
   case A_surfxml_link___ctn_direction_DOWN:
-    link      = engine->split_duplex_link_by_name(std::string(A_surfxml_link___ctn_id));
+    link      = engine->split_duplex_link_by_name(A_surfxml_link___ctn_id);
     direction = simgrid::s4u::LinkInRoute::Direction::DOWN;
     break;
   default:
@@ -523,7 +523,7 @@ void ETag_surfxml_backbone()
 {
   auto link = std::make_unique<simgrid::kernel::routing::LinkCreationArgs>();
 
-  link->id = std::string(A_surfxml_backbone_id);
+  link->id = A_surfxml_backbone_id;
   link->bandwidths.push_back(xbt_parse_get_bandwidth(
       surf_parsed_filename, surf_parse_lineno, A_surfxml_backbone_bandwidth, "bandwidth of backbone " + link->id));
   link->latency = xbt_parse_get_time(surf_parsed_filename, surf_parse_lineno, A_surfxml_backbone_latency,
@@ -839,7 +839,7 @@ void surf_parse_open(const std::string& file)
 
   surf_file_to_parse = surf_fopen(file, "r");
   if (surf_file_to_parse == nullptr)
-    throw std::invalid_argument(std::string("Unable to open '") + file + "' from '" + simgrid::xbt::Path().get_name() +
+    throw std::invalid_argument("Unable to open '" + file + "' from '" + simgrid::xbt::Path().get_name() +
                                 "'. Does this file exist?");
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse__switch_to_buffer(surf_input_buffer);
index 7b44c9f..7c09e5c 100644 (file)
@@ -61,7 +61,7 @@ public:
             frame_name.find("simcall_run_answered") != std::string::npos ||
             frame_name.find("simcall_run_blocking") != std::string::npos) {
           frame_count = 0;
-          ss.str(std::string()); // This is how you clear a stringstream in C++. clear() is something else :'(
+          ss.str(""); // This is how you clear a stringstream in C++. clear() is something else :'(
         }
         if (frame_name == "main")
           break;
index 64c5b99..694f8e2 100644 (file)
@@ -101,10 +101,7 @@ public:
 template <> class ConfigType<std::string> {
 public:
   static constexpr const char* type_name = "string";
-  static inline std::string parse(const char* value)
-  {
-    return std::string(value);
-  }
+  static inline std::string parse(const char* value) { return value; }
 };
 template <> class ConfigType<bool> {
 public:
index 916c77b..d4e4fdd 100644 (file)
@@ -411,7 +411,7 @@ static xbt_log_setting_t _xbt_log_parse_setting(const char *control_string)
       throw std::invalid_argument(simgrid::xbt::string_printf("Unknown appender log type: '%s'", value));
     }
   } else if (strncmp(option, "fmt", option_len) == 0) {
-    set.fmt = std::string(value);
+    set.fmt = value;
   } else {
     xbt_die("Unknown setting of the log category: '%.*s'", static_cast<int>(option_len), option);
   }
index 90e5c5f..ceaf8d8 100644 (file)
@@ -202,7 +202,7 @@ std::vector<VmMap> get_memory_map(pid_t pid)
 #elif defined __linux__
   /* Open the actual process's proc maps file and create the memory_map_t */
   /* to be returned. */
-  std::string path = std::string("/proc/") + std::to_string(pid) + "/maps";
+  std::string path = "/proc/" + std::to_string(pid) + "/maps";
   std::ifstream fp;
   fp.rdbuf()->pubsetbuf(nullptr, 0);
   fp.open(path);
index fd280c9..68817d5 100644 (file)
@@ -28,22 +28,20 @@ simgrid::xbt::Path::Path()
   std::array<char, 2048> buffer;
   const char* cwd = getcwd(buffer.data(), 2048);
   xbt_assert(cwd != nullptr, "Error during getcwd: %s", strerror(errno));
-  path_ = std::string(cwd);
+  path_ = cwd;
 #else
-  path_ = std::string(".");
+  path_ = ".";
 #endif
 }
 
 std::string simgrid::xbt::Path::get_dir_name() const
 {
   std::string p(path_);
-  const char* res = dirname(&p[0]);
-  return std::string(res, strlen(res));
+  return dirname(&p[0]);
 }
 
 std::string simgrid::xbt::Path::get_base_name() const
 {
   std::string p(path_);
-  const char* res = basename(&p[0]);
-  return std::string(res, strlen(res));
+  return basename(&p[0]);
 }
index 8a8929c..192d74e 100644 (file)
@@ -62,9 +62,9 @@ static double xbt_parse_get_value_with_unit(const std::string& filename, int lin
   double res      = strtod(string.c_str(), &endptr);
   const char* ptr = endptr; // for const-correctness
   if (errno == ERANGE)
-    throw simgrid::ParseError(filename, lineno, std::string("value out of range: ") + string);
+    throw simgrid::ParseError(filename, lineno, "value out of range: " + string);
   if (ptr == string)
-    throw simgrid::ParseError(filename, lineno, std::string("cannot parse number:") + string);
+    throw simgrid::ParseError(filename, lineno, "cannot parse number:" + string);
   if (ptr[0] == '\0') {
     // Ok, 0 can be unit-less
     if (res != 0 && not entity_kind.empty())
index f478b5a..4288a58 100644 (file)
@@ -52,7 +52,7 @@ bool ReplayReader::get(ReplayAction* action)
 
 static std::unique_ptr<ReplayAction> get_action(const char* name)
 {
-  if (auto queue_elt = action_queues.find(std::string(name)); queue_elt != action_queues.end()) {
+  if (auto queue_elt = action_queues.find(name); queue_elt != action_queues.end()) {
     if (auto& my_queue = queue_elt->second; not my_queue.empty()) {
       // Get something from my queue and return it
       auto action = std::move(my_queue.front());
@@ -154,7 +154,7 @@ int replay_runner(const char* actor_name, const char* trace_filename)
  */
 void xbt_replay_action_register(const char* action_name, const action_fun& function)
 {
-  simgrid::xbt::action_funs[std::string(action_name)] = function;
+  simgrid::xbt::action_funs[action_name] = function;
 }
 
 /**
@@ -165,7 +165,7 @@ void xbt_replay_action_register(const char* action_name, const action_fun& funct
  */
 action_fun xbt_replay_action_get(const char* action_name)
 {
-  return simgrid::xbt::action_funs.at(std::string(action_name));
+  return simgrid::xbt::action_funs.at(action_name);
 }
 
 void xbt_replay_set_tracefile(const std::string& filename)
index b6334cf..9554fc3 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc, char* argv[])
                                  "the only worker gets killed.");
   sg4::Host* master_host = rootzone->create_host("lilibeth 0", 1e9); // Host where the master will stay
   for (int i = 1; i < cfg_host_count; i++) {
-    auto hostname = std::string("lilibeth ") + std::to_string(i);
+    auto hostname = "lilibeth " + std::to_string(i);
     auto* host    = rootzone->create_host(hostname, 1e9);
     sg4::LinkInRoute link(rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal());
     rootzone->add_route(master_host->get_netpoint(), host->get_netpoint(), nullptr, nullptr, {link}, true);
index e8b775b..7744647 100644 (file)
@@ -21,8 +21,7 @@ public:
     /* Make a vector of the mailboxes to use */
     std::vector<sg4::Mailbox*> mboxes;
 
-    std::string msg_content =
-        std::string("Hello, I'm alive and running on ") + std::string(sg4::this_actor::get_host()->get_name());
+    std::string msg_content = "Hello, I'm alive and running on " + sg4::this_actor::get_host()->get_name();
     for (const auto* host : hosts_) {
       auto* payload = new std::string(msg_content);
       /* Create a communication representing the ongoing communication, and store it in pending_comms */
@@ -93,7 +92,7 @@ int main(int argc, char* argv[])
   sg4::Actor::create("sender", host_list[0], Sender(host_list));
   /* create receiver in every host */
   for (auto* host : host_list) {
-    sg4::Actor::create(std::string("receiver-") + std::string(host->get_name()), host, Receiver());
+    sg4::Actor::create("receiver-" + host->get_name(), host, Receiver());
   }
 
   /* runs the simulation */