Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The result of "std::move" should not be passed as a const reference (Sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 29 Jun 2023 07:32:33 +0000 (09:32 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 29 Jun 2023 07:32:33 +0000 (09:32 +0200)
src/mc/explo/udpor/Configuration.cpp
src/mc/explo/udpor/Configuration_test.cpp
src/mc/explo/udpor/EventSet_test.cpp
src/mc/explo/udpor/ExtensionSetCalculator.cpp

index 600a4f7..2dd00cb 100644 (file)
@@ -213,7 +213,7 @@ std::optional<Configuration> Configuration::compute_k_partial_alternative_to(con
     for (const auto& event_in_spike : spikes) {
       events.push_back(*event_in_spike);
     }
-    return EventSet(std::move(events));
+    return EventSet(events);
   };
   const auto alternative =
       std::find_if(comb.combinations_begin(), comb.combinations_end(),
index 0105b0b..a20f382 100644 (file)
@@ -377,15 +377,13 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
 
     SECTION("Forward direction")
     {
-      auto ordered_events          = C.get_topologically_sorted_events();
-      const auto ordered_event_set = EventSet(std::move(ordered_events));
+      const auto ordered_event_set = EventSet(C.get_topologically_sorted_events());
       REQUIRE(events_seen == ordered_event_set);
     }
 
     SECTION("Reverse direction")
     {
-      auto ordered_events          = C.get_topologically_sorted_events_of_reverse_graph();
-      const auto ordered_event_set = EventSet(std::move(ordered_events));
+      const auto ordered_event_set = EventSet(C.get_topologically_sorted_events_of_reverse_graph());
       REQUIRE(events_seen == ordered_event_set);
     }
   }
index afe4ea5..4c8287c 100644 (file)
@@ -770,15 +770,15 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Moving into a collection")
   EventSet C_copy = C;
   EventSet D_copy = D;
 
-  std::vector<const UnfoldingEvent*> actual_A = std::move(A).move_into_vector();
-  std::vector<const UnfoldingEvent*> actual_B = std::move(B).move_into_vector();
-  std::vector<const UnfoldingEvent*> actual_C = std::move(C).move_into_vector();
-  std::vector<const UnfoldingEvent*> actual_D = std::move(D).move_into_vector();
-
-  EventSet A_copy_remade(std::move(actual_A));
-  EventSet B_copy_remade(std::move(actual_B));
-  EventSet C_copy_remade(std::move(actual_C));
-  EventSet D_copy_remade(std::move(actual_D));
+  const std::vector<const UnfoldingEvent*> actual_A = std::move(A).move_into_vector();
+  const std::vector<const UnfoldingEvent*> actual_B = std::move(B).move_into_vector();
+  const std::vector<const UnfoldingEvent*> actual_C = std::move(C).move_into_vector();
+  const std::vector<const UnfoldingEvent*> actual_D = std::move(D).move_into_vector();
+
+  EventSet A_copy_remade(actual_A);
+  EventSet B_copy_remade(actual_B);
+  EventSet C_copy_remade(actual_C);
+  EventSet D_copy_remade(actual_D);
 
   REQUIRE(A_copy == A_copy_remade);
   REQUIRE(B_copy == B_copy_remade);
index 6456fff..11c9ae8 100644 (file)
@@ -53,7 +53,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommSend(const Configuration&
 {
   EventSet exC;
 
-  const auto send_action        = std::static_pointer_cast<CommSendTransition>(std::move(action));
+  const auto send_action        = std::static_pointer_cast<CommSendTransition>(action);
   const auto pre_event_a_C      = C.pre_event(send_action->aid_);
   const unsigned sender_mailbox = send_action->get_mailbox();
 
@@ -95,7 +95,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommRecv(const Configuration&
 {
   EventSet exC;
 
-  const auto recv_action      = std::static_pointer_cast<CommRecvTransition>(std::move(action));
+  const auto recv_action      = std::static_pointer_cast<CommRecvTransition>(action);
   const unsigned recv_mailbox = recv_action->get_mailbox();
   const auto pre_event_a_C    = C.pre_event(recv_action->aid_);
 
@@ -301,7 +301,7 @@ EventSet ExtensionSetCalculator::partially_extend_CommWait(const Configuration&
       // `WaitAny()` is always disabled in `config(K)`; hence, it
       // is independent of any transition in `config(K)` (according
       // to formal definition of independence)
-      const auto K        = EventSet({e, pre_event_a_C.value_or(e)});
+      auto K              = EventSet({e, pre_event_a_C.value_or(e)});
       const auto config_K = History(K);
       if (not config_K.contains(e_issuer)) {
         continue;