Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use const& for std::string parameters.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 16 Apr 2021 08:59:45 +0000 (10:59 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 16 Apr 2021 14:10:44 +0000 (16:10 +0200)
examples/cpp/network-ns3-wifi/s4u-network-ns3-wifi.cpp
examples/cpp/platform-properties/s4u-platform-properties.cpp
src/surf/network_ns3.cpp
src/surf/xml/surfxml_sax_cb.cpp

index bd47083..648d86a 100644 (file)
@@ -18,7 +18,7 @@ public:
   Message(const std::string& sender_, int size_) : sender(sender_), size(size_) {}
 };
 
-static void sender(std::string mailbox, double msg_size, unsigned sleep_time)
+static void sender(const std::string& mailbox, double msg_size, unsigned sleep_time)
 {
   simgrid::s4u::this_actor::sleep_for(sleep_time);
   auto* mbox = simgrid::s4u::Mailbox::by_name(mailbox);
@@ -26,7 +26,7 @@ static void sender(std::string mailbox, double msg_size, unsigned sleep_time)
   mbox->put(msg, msg_size);
 }
 
-static void receiver(std::string mailbox)
+static void receiver(const std::string& mailbox)
 {
   auto* mbox = simgrid::s4u::Mailbox::by_name(mailbox);
   auto msg   = mbox->get_unique<Message>();
index 0327ff8..1eb7ff4 100644 (file)
@@ -25,7 +25,7 @@ static void test_host(const std::string& hostname)
   for (auto const& kv : *hostprops)
     keys.push_back(kv.first);
   std::sort(keys.begin(), keys.end());
-  for (std::string key : keys)
+  for (const std::string& key : keys)
     XBT_INFO("  Host property: '%s' -> '%s'", key.c_str(), hostprops->at(key).c_str());
 
   XBT_INFO("== Try to get a host property that does not exist");
@@ -57,7 +57,7 @@ static void test_host(const std::string& hostname)
   for (auto const& kv : *zoneprops)
     keys.push_back(kv.first);
   std::sort(keys.begin(), keys.end());
-  for (std::string key : keys)
+  for (const std::string& key : keys)
     XBT_INFO("  Zone property: '%s' -> '%s'", key.c_str(), zoneprops->at(key).c_str());
 }
 
index 71f8614..7868a63 100644 (file)
@@ -270,7 +270,7 @@ static simgrid::config::Flag<std::string>
 static simgrid::config::Flag<std::string> ns3_seed(
     "ns3/seed",
     "The random seed provided to ns-3. Either 'time' to seed with time(), blank to not set (default), or a number.", "",
-    [](std::string val) {
+    [](const std::string& val) {
       if (val.length() == 0)
         return;
       if (strcasecmp(val.c_str(), "time") == 0) {
index 900b3aa..4692ecd 100644 (file)
@@ -732,7 +732,7 @@ void ETag_surfxml_config()
     keys.push_back(kv.first);
   }
   std::sort(keys.begin(), keys.end());
-  for (std::string key : keys) {
+  for (const std::string& key : keys) {
     if (simgrid::config::is_default(key.c_str())) {
       std::string cfg = key + ":" + current_property_set.at(key);
       simgrid::config::set_parse(cfg);