From 7209dc4e87c01c9084be72a08193b7ebdd605919 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Apr 2023 08:39:35 +0200 Subject: [PATCH] Remove unnecessary temporary objects and destructors --- src/core/system_parameters/gnss_satellite.cc | 22 ++++++++++++------- .../gps_l1_ca_pcps_acquisition_test.cc | 6 ----- .../adapter/adapter_test.cc | 4 ---- .../filter/fir_filter_test.cc | 7 +++--- .../filter/notch_filter_lite_test.cc | 12 +++++----- .../filter/notch_filter_test.cc | 12 +++++----- .../filter/pulse_blanking_filter_test.cc | 14 +++++++----- .../cpu_multicorrelator_real_codes_test.cc | 8 +++---- .../tracking/cpu_multicorrelator_test.cc | 8 +++---- .../galileo_e1_dll_pll_veml_tracking_test.cc | 5 +---- 10 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 7f1b1030c..2a974cc0a 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -30,10 +30,10 @@ Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_) void Gnss_Satellite::reset() { - system = std::string(""); - block = std::string(""); - PRN = 0; - rf_link = 0; + this->system.clear(); + this->block.clear(); + this->PRN = 0; + this->rf_link = 0; } @@ -103,7 +103,10 @@ Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept PRN(other.PRN), rf_link(other.rf_link) { - other.reset(); + other.system.clear(); + other.block.clear(); + other.PRN = 0; + other.rf_link = 0; } @@ -116,7 +119,10 @@ Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other) noexcept block = std::move(other.block); PRN = other.PRN; rf_link = other.rf_link; - other.reset(); + other.system.clear(); + other.block.clear(); + other.PRN = 0; + other.rf_link = 0; } return *this; } @@ -621,7 +627,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ block_ = std::string("FOC-FM19"); // Galileo Full Operational Capability (FOC) satellite FM19 / GSAT0219, launched on Jul. 25, 2018. UNDER COMMISSIONING. break; default: - block_ = std::string("Unknown(Simulated)"); + block_ = std::string("Unknown"); } } if (system_ == "Beidou") @@ -768,7 +774,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ block_ = std::string("BeiDou-3 GEOG3"); // launched 2020/06/2023 break; default: - block_ = std::string("Unknown(Simulated)"); + block_ = std::string("Unknown"); } } return block_; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index e9c5d9e45..76056cb3b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -72,7 +72,6 @@ private: public: int rx_message{0}; - ~GpsL1CaPcpsAcquisitionTest_msg_rx() override; //!< Default destructor }; @@ -115,9 +114,6 @@ GpsL1CaPcpsAcquisitionTest_msg_rx::GpsL1CaPcpsAcquisitionTest_msg_rx() } -GpsL1CaPcpsAcquisitionTest_msg_rx::~GpsL1CaPcpsAcquisitionTest_msg_rx() = default; - - // ########################################################### class GpsL1CaPcpsAcquisitionTest : public ::testing::Test @@ -131,8 +127,6 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsAcquisitionTest() override = default; - void init(); void plot_grid() const; diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index d43d459d6..26ff99a38 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -38,7 +38,6 @@ class DataTypeAdapter : public ::testing::Test { public: DataTypeAdapter(); - ~DataTypeAdapter() override; int run_byte_to_short_block() const; int run_ibyte_to_cbyte_block() const; int run_ibyte_to_complex_block() const; @@ -67,9 +66,6 @@ DataTypeAdapter::DataTypeAdapter() } -DataTypeAdapter::~DataTypeAdapter() = default; - - int DataTypeAdapter::run_ishort_to_cshort_block() const { std::shared_ptr config = std::make_shared(); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index 8bd2d98c4..a0d064dac 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -44,23 +44,24 @@ DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the class FirFilterTest : public ::testing::Test { protected: - FirFilterTest() : item_size(sizeof(gr_complex)) + FirFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~FirFilterTest() override = default; void init(); void configure_cbyte_cbyte(); void configure_cbyte_gr_complex(); void configure_gr_complex_gr_complex(); void configure_cshort_cshort(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; size_t item_size; - int nsamples = FLAGS_filter_test_nsamples; + int nsamples; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index 12d6ddce4..db12b3bfc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to fil class NotchFilterLiteTest : public ::testing::Test { protected: - NotchFilterLiteTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_notch_filter_lite_test_nsamples) + NotchFilterLiteTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_notch_filter_lite_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~NotchFilterLiteTest() override = default; - bool stop = false; - std::thread ch_thread; void start_queue(); void wait_message(); void process_message(); void stop_queue(); - pmt::pmt_t message; - void init(); void configure_gr_complex_gr_complex(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; + pmt::pmt_t message; + std::thread ch_thread; size_t item_size; int nsamples; + bool stop{false}; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc index 4c2a3cb4a..36c7346a2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc @@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_test_nsamples, 1000000, "Number of samples to filter i class NotchFilterTest : public ::testing::Test { protected: - NotchFilterTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_notch_filter_test_nsamples) + NotchFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_notch_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~NotchFilterTest() override = default; - bool stop = false; - std::thread ch_thread; void start_queue(); void wait_message(); void process_message(); void stop_queue(); - pmt::pmt_t message; - void init(); void configure_gr_complex_gr_complex(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; + std::thread ch_thread; + pmt::pmt_t message; size_t item_size; int nsamples; + bool stop{false}; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc index 2bc731620..63038b5f1 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc @@ -43,26 +43,28 @@ DEFINE_int32(pb_filter_test_nsamples, 1000000, "Number of samples to filter in t class PulseBlankingFilterTest : public ::testing::Test { protected: - PulseBlankingFilterTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_pb_filter_test_nsamples) + PulseBlankingFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_pb_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~PulseBlankingFilterTest() override = default; - bool stop = false; - std::thread ch_thread; + void start_queue(); void wait_message(); void process_message(); void stop_queue(); void init(); void configure_gr_complex_gr_complex(); + + std::thread ch_thread; std::shared_ptr> queue; - gr::top_block_sptr top_block; std::shared_ptr config; + gr::top_block_sptr top_block; + pmt::pmt_t message; size_t item_size; int nsamples; - pmt::pmt_t message; + bool stop{false}; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc index 57ea5dfbe..34c4894d7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc @@ -126,14 +126,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes, + thread_pool.emplace_back(run_correlator_cpu_real_codes, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_code_phase_rate_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) @@ -224,14 +224,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTimeAlloc) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes, + thread_pool.emplace_back(run_correlator_cpu_real_codes, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_code_phase_rate_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc index 773b188b0..339205f43 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc @@ -122,13 +122,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.push_back(std::thread(run_correlator_cpu, + thread_pool.emplace_back(run_correlator_cpu, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) @@ -220,13 +220,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTimeAlloc) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.push_back(std::thread(run_correlator_cpu, + thread_pool.emplace_back(run_correlator_cpu, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc index 734d70af2..0519b3de3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc @@ -45,11 +45,8 @@ protected: { factory = std::make_shared(); config = std::make_shared(); - gnss_synchro = Gnss_Synchro(); } - ~GalileoE1DllPllVemlTrackingInternalTest() override = default; - void init(); std::shared_ptr> queue; @@ -58,8 +55,8 @@ protected: std::shared_ptr config; Gnss_Synchro gnss_synchro{}; size_t item_size; - bool stop{false}; int message{0}; + bool stop{false}; };