From f7efcf54d9cee11fa6d3be84da7ae2f7f83fd694 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Oct 2026 12:26:55 +0200 Subject: [PATCH] Fix minor performance ineficiencies --- src/core/receiver/gnss_flowgraph.cc | 4 ++-- src/core/system_parameters/beidou_ldpc.cc | 3 ++- .../control-plane/gnss_flowgraph_test.cc | 2 +- .../adapter/stream_batcher_test.cc | 19 +++++++++++++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index f6cdc388a..1f9d6d62c 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1438,7 +1438,7 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() StreamEndpoint upstream; upstream.block = sig_conditioner_.at(i)->get_right_block(); // The array conditioner is already wired above. - connect_conditioner_output(static_cast(i), upstream); + connect_conditioner_output(static_cast(i), std::move(upstream)); signal_conditioner_ID++; } else @@ -1468,7 +1468,7 @@ int GNSSFlowgraph::connect_signal_sources_to_signal_conditioners() // A single output may intentionally feed several // conditioners (for example, different subbands). } - connect_conditioner_output(signal_conditioner_ID, upstream); + connect_conditioner_output(signal_conditioner_ID, std::move(upstream)); signal_conditioner_ID++; } } diff --git a/src/core/system_parameters/beidou_ldpc.cc b/src/core/system_parameters/beidou_ldpc.cc index de88a06d1..ba31bb844 100644 --- a/src/core/system_parameters/beidou_ldpc.cc +++ b/src/core/system_parameters/beidou_ldpc.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include namespace @@ -529,7 +530,7 @@ bool decode_block( std::vector hard_symbol; std::vector channel_llr; initialize_channel_llr(bit_llr, n, hard_symbol, channel_llr); - hard_codeword = hard_symbol; + hard_codeword = std::move(hard_symbol); if (syndrome_is_zero(graph, hard_codeword)) { diff --git a/tests/unit-tests/control-plane/gnss_flowgraph_test.cc b/tests/unit-tests/control-plane/gnss_flowgraph_test.cc index 40951e448..ccc139690 100644 --- a/tests/unit-tests/control-plane/gnss_flowgraph_test.cc +++ b/tests/unit-tests/control-plane/gnss_flowgraph_test.cc @@ -337,7 +337,7 @@ TEST_F(ConditionedFlowgraphTest, DefaultPlanningNeedsNoConfigurationEdits) graph.connect(); ASSERT_TRUE(graph.connected()); ASSERT_EQ(1U, graph.conditioner_scheduling_plans().size()); - const auto plan = graph.conditioner_scheduling_plans()[0]; + const auto& plan = graph.conditioner_scheduling_plans()[0]; EXPECT_TRUE(plan.automatic); EXPECT_EQ(3U, plan.readers); // Acquisition, tracking, and sample counter. EXPECT_EQ(20000U, plan.batch_items); diff --git a/tests/unit-tests/signal-processing-blocks/adapter/stream_batcher_test.cc b/tests/unit-tests/signal-processing-blocks/adapter/stream_batcher_test.cc index 61cfcfb24..08e4b53d4 100644 --- a/tests/unit-tests/signal-processing-blocks/adapter/stream_batcher_test.cc +++ b/tests/unit-tests/signal-processing-blocks/adapter/stream_batcher_test.cc @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef GR_GREATER_38 #include @@ -395,7 +396,7 @@ TEST_F(StreamBatcherTest, ManyReadersAndSmallWorkAllowance) { auto sink = gr::blocks::vector_sink_i::make(); top->connect(batcher, 0, sink, 0); - sinks.push_back(sink); + sinks.push_back(std::move(sink)); } ASSERT_TRUE(run(top)); std::vector expected(65537); @@ -447,7 +448,7 @@ TEST_F(StreamBatcherTest, StopDuringAccumulation) top->start(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); top->stop(); - auto done = std::async(std::launch::async, [top]() { top->wait(); }); + auto done = std::async(std::launch::async, [](const gr::top_block_sptr& graph) { graph->wait(); }, std::move(top)); EXPECT_EQ(std::future_status::ready, done.wait_for(std::chrono::seconds(2))); done.get(); } @@ -519,7 +520,10 @@ TEST_F(StreamBatcherTest, AllConditionerStageCombinationsPreserveInversion) } auto conditioner = block_factory::GetSignalConditioner(&config); auto* adapter = dynamic_cast(conditioner.get()); - ASSERT_NE(nullptr, adapter); + if (adapter == nullptr) + { + FAIL() << "GetSignalConditioner did not return a SignalConditioner"; + } adapter->set_remove_identity(true); auto top = gr::make_top_block("conditioner_chain_test"); std::vector samples(1025, gr_complex(0.25F, -0.75F)); @@ -544,7 +548,7 @@ TEST_F(StreamBatcherTest, AllConditionerStageCombinationsPreserveInversion) } EXPECT_EQ(samples, sink->data()) << mask; conditioner->disconnect(top); - conditioner->disconnect(top); + conditioner->disconnect(std::move(top)); } } @@ -583,7 +587,10 @@ TEST_F(StreamBatcherTest, ConversionRemainsWhenCopiesAreRemoved) config.set_property("DataTypeAdapter.inverted_spectrum", "true"); auto conditioner = block_factory::GetSignalConditioner(&config); auto* adapter = dynamic_cast(conditioner.get()); - ASSERT_NE(nullptr, adapter); + if (adapter == nullptr) + { + FAIL() << "GetSignalConditioner did not return a SignalConditioner"; + } adapter->set_remove_identity(true); ASSERT_FALSE(conditioner->is_identity()); std::vector input(2050); @@ -617,7 +624,7 @@ TEST_F(StreamBatcherTest, DeadlinePublishesWithoutFurtherInputOrEof) auto sink = gnss_make_shared(); top->connect(source, 0, batcher, 0); top->connect(batcher, 0, sink, 0); - sinks.push_back(sink); + sinks.push_back(std::move(sink)); } top->start(); // Allow scheduler jitter, but do not accept the legacy 250 ms input poll.