Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't build useless temporary object (sonar, c++17).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 26 Apr 2022 07:55:12 +0000 (09:55 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 26 Apr 2022 11:00:03 +0000 (13:00 +0200)
examples/cpp/app-bittorrent/s4u-peer.cpp
src/instr/instr_paje_types.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/StarZone.cpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_shared.cpp
src/surf/network_ib.cpp

index 409418f..83c22de 100644 (file)
@@ -121,7 +121,7 @@ bool Peer::getPeersFromTracker()
     // Add the peers the tracker gave us to our peer list.
     for (auto const& peer_id : answer->getPeers())
       if (id != peer_id)
-        connected_peers.try_emplace(peer_id, Connection(peer_id));
+        connected_peers.try_emplace(peer_id, peer_id);
   } catch (const simgrid::TimeoutException&) {
     XBT_DEBUG("Timeout expired when requesting peers to tracker");
     return false;
@@ -317,7 +317,7 @@ void Peer::handleMessage()
       // Check if the peer is in our connection list.
       if (remote_peer == nullptr) {
         XBT_DEBUG("This peer %d was unknown, answer to its handshake", message->peer_id);
-        connected_peers.try_emplace(message->peer_id, Connection(message->peer_id));
+        connected_peers.try_emplace(message->peer_id, message->peer_id);
         sendMessage(message->return_mailbox, MessageType::HANDSHAKE, message_size(MessageType::HANDSHAKE));
       }
       // Send our bitfield to the peer
index 0e31281..7defa58 100644 (file)
@@ -137,7 +137,7 @@ void ValueType::add_entity_value(const std::string& name, const std::string& col
   auto it = values_.find(name);
   if (it == values_.end()) {
     XBT_DEBUG("new value %s, child of %s", name.c_str(), get_cname());
-    values_.try_emplace(name, EntityValue(name, color, this));
+    values_.try_emplace(name, name, color, this);
   }
 }
 
index 150bf22..93a9c6e 100644 (file)
@@ -113,7 +113,7 @@ void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Rou
     insert_link_latency(route->link_list_, e_route->link_list_, lat);
   }
 
-  auto elm                             = route_cache_.try_emplace(src_id, std::vector<unsigned long>());
+  auto elm                             = route_cache_.try_emplace(src_id);
   std::vector<unsigned long>& pred_arr = elm.first->second;
 
   if (elm.second) { /* new element was inserted (not cached mode, or cache miss) */
index 6d4b0f7..ee9a808 100644 (file)
@@ -170,7 +170,7 @@ void StarZone::do_seal()
 {
   /* add default empty links if nothing was configured by user */
   for (auto const& node : get_vertices()) {
-    auto route = routes_.try_emplace(node->id(), StarRoute());
+    auto route = routes_.try_emplace(node->id());
     if (route.second) {
       route.first->second.links_down_set = true;
       route.first->second.links_up_set   = true;
index 06f9d85..921f3c0 100644 (file)
@@ -56,7 +56,7 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_
   if (code != nullptr) // When started with smpirun, we will not execute a function
     simgrid::s4u::Engine::get_instance()->register_function(name, code);
 
-  smpi_instances.try_emplace(name, Instance(num_processes));
+  smpi_instances.try_emplace(name, num_processes);
 }
 
 void smpi_deployment_register_process(const std::string& instance_id, int rank, const simgrid::s4u::Actor* actor)
index 4edd30f..aec5e05 100644 (file)
@@ -126,7 +126,7 @@ static void *smpi_shared_malloc_local(size_t size, const char *file, int line)
 {
   void* mem;
   smpi_source_location loc(file, line);
-  auto res  = allocs.try_emplace(loc, shared_data_t());
+  auto res  = allocs.try_emplace(loc);
   auto data = res.first;
   if (res.second) {
     // The new element was inserted.
index c6362f6..6999d57 100644 (file)
@@ -53,7 +53,7 @@ void NetworkIBModel::IB_create_host_callback(s4u::Host const& host)
 {
   static int id = 0;
   auto* ibModel = static_cast<NetworkIBModel*>(host.get_netpoint()->get_englobing_zone()->get_network_model().get());
-  ibModel->active_nodes.try_emplace(host.get_name(), IBNode(id));
+  ibModel->active_nodes.try_emplace(host.get_name(), id);
   id++;
 }