Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid unnecessary copy by using a 'const' reference (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Dec 2020 13:32:01 +0000 (14:32 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Dec 2020 20:49:00 +0000 (21:49 +0100)
examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
src/instr/instr_paje_header.cpp
src/instr/instr_platform.cpp
src/surf/network_wifi.cpp
src/xbt/xbt_parse_units.cpp

index d7ebe32..84dad44 100644 (file)
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
   /* - Display Host properties */
   for (auto h : e.get_all_hosts()) {
     XBT_INFO("*** %s properties ****", h->get_cname());
-    for (auto kv : *h->get_properties())
+    for (auto const& kv : *h->get_properties())
       XBT_INFO("  %s -> %s", kv.first.c_str(), kv.second.c_str());
   }
 
index ed5a2b8..693a430 100644 (file)
@@ -18,7 +18,7 @@ simgrid::s4u::SemaphorePtr sem_full  = simgrid::s4u::Semaphore::create(0); /* in
 
 static void producer(const std::vector<std::string>* args)
 {
-  for (auto str : *args) {
+  for (auto const& str : *args) {
     sem_empty->acquire();
     XBT_INFO("Pushing '%s'", str.c_str());
     buffer = str.c_str();
index 6cd678e..6721856 100644 (file)
@@ -19,7 +19,7 @@ void dump_generator_version()
   tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
                << "." << SIMGRID_VERSION_PATCH << std::endl;
   tracing_file << "#[";
-  for (auto str : simgrid::xbt::cmdline) {
+  for (auto const& str : simgrid::xbt::cmdline) {
     tracing_file << str << " ";
   }
   tracing_file << "]" << std::endl;
index 9237011..f08514b 100644 (file)
@@ -135,7 +135,7 @@ static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, simgr
   std::map<std::string, xbt_edge_t> edges;
 
   netzone->get_impl()->get_graph(graph, &nodes, &edges);
-  for (auto elm : edges) {
+  for (auto const& elm : edges) {
     const xbt_edge* edge = elm.second;
     linkContainers(simgrid::instr::Container::by_name(static_cast<const char*>(edge->src->data)),
                    simgrid::instr::Container::by_name(static_cast<const char*>(edge->dst->data)), filter);
index 05cdc71..b0c922d 100644 (file)
@@ -71,7 +71,7 @@ void NetworkWifiLink::refresh_decay_bandwidths(){
   int nSTA = get_host_count();
 
   std::vector<Metric> new_bandwidths;
-  for (auto bandwidth : bandwidths_){
+  for (auto const& bandwidth : bandwidths_) {
     // Instantiate decay model relatively to the actual bandwidth
     double max_bw=bandwidth.peak;
     double min_bw=bandwidth.peak-(wifi_max_rate_-wifi_min_rate_);
index 7321a37..7bdcbf9 100644 (file)
@@ -120,7 +120,7 @@ std::vector<double> xbt_parse_get_bandwidths(const std::string& filename, int li
   std::vector<double> bandwidths;
   std::vector<std::string> tokens;
   boost::split(tokens, string, boost::is_any_of(";,"));
-  for (auto token : tokens) {
+  for (auto const& token : tokens) {
     bandwidths.push_back(surf_parse_get_value_with_unit(
         filename, lineno, token.c_str(), units, entity_kind, name,
         "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps"));