1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-08-06 13:55:06 +00:00

Remove unnecessary temporary objects and destructors

This commit is contained in:
Carles Fernandez 2023-04-04 08:39:35 +02:00
parent bf3c3918ef
commit 7209dc4e87
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
10 changed files with 47 additions and 51 deletions

View File

@ -30,10 +30,10 @@ Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_)
void Gnss_Satellite::reset() void Gnss_Satellite::reset()
{ {
system = std::string(""); this->system.clear();
block = std::string(""); this->block.clear();
PRN = 0; this->PRN = 0;
rf_link = 0; this->rf_link = 0;
} }
@ -103,7 +103,10 @@ Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept
PRN(other.PRN), PRN(other.PRN),
rf_link(other.rf_link) 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); block = std::move(other.block);
PRN = other.PRN; PRN = other.PRN;
rf_link = other.rf_link; rf_link = other.rf_link;
other.reset(); other.system.clear();
other.block.clear();
other.PRN = 0;
other.rf_link = 0;
} }
return *this; 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. block_ = std::string("FOC-FM19"); // Galileo Full Operational Capability (FOC) satellite FM19 / GSAT0219, launched on Jul. 25, 2018. UNDER COMMISSIONING.
break; break;
default: default:
block_ = std::string("Unknown(Simulated)"); block_ = std::string("Unknown");
} }
} }
if (system_ == "Beidou") 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 block_ = std::string("BeiDou-3 GEOG3"); // launched 2020/06/2023
break; break;
default: default:
block_ = std::string("Unknown(Simulated)"); block_ = std::string("Unknown");
} }
} }
return block_; return block_;

View File

@ -72,7 +72,6 @@ private:
public: public:
int rx_message{0}; 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 class GpsL1CaPcpsAcquisitionTest : public ::testing::Test
@ -131,8 +127,6 @@ protected:
gnss_synchro = Gnss_Synchro(); gnss_synchro = Gnss_Synchro();
} }
~GpsL1CaPcpsAcquisitionTest() override = default;
void init(); void init();
void plot_grid() const; void plot_grid() const;

View File

@ -38,7 +38,6 @@ class DataTypeAdapter : public ::testing::Test
{ {
public: public:
DataTypeAdapter(); DataTypeAdapter();
~DataTypeAdapter() override;
int run_byte_to_short_block() const; int run_byte_to_short_block() const;
int run_ibyte_to_cbyte_block() const; int run_ibyte_to_cbyte_block() const;
int run_ibyte_to_complex_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 int DataTypeAdapter::run_ishort_to_cshort_block() const
{ {
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>(); std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();

View File

@ -44,23 +44,24 @@ DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the
class FirFilterTest : public ::testing::Test class FirFilterTest : public ::testing::Test
{ {
protected: protected:
FirFilterTest() : item_size(sizeof(gr_complex)) FirFilterTest() : item_size(sizeof(gr_complex)),
nsamples(FLAGS_filter_test_nsamples)
{ {
queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>(); queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
config = std::make_shared<InMemoryConfiguration>(); config = std::make_shared<InMemoryConfiguration>();
} }
~FirFilterTest() override = default;
void init(); void init();
void configure_cbyte_cbyte(); void configure_cbyte_cbyte();
void configure_cbyte_gr_complex(); void configure_cbyte_gr_complex();
void configure_gr_complex_gr_complex(); void configure_gr_complex_gr_complex();
void configure_cshort_cshort(); void configure_cshort_cshort();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
size_t item_size; size_t item_size;
int nsamples = FLAGS_filter_test_nsamples; int nsamples;
}; };

View File

@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to fil
class NotchFilterLiteTest : public ::testing::Test class NotchFilterLiteTest : public ::testing::Test
{ {
protected: 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<Concurrent_Queue<pmt::pmt_t>>(); queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
config = std::make_shared<InMemoryConfiguration>(); config = std::make_shared<InMemoryConfiguration>();
} }
~NotchFilterLiteTest() override = default;
bool stop = false;
std::thread ch_thread;
void start_queue(); void start_queue();
void wait_message(); void wait_message();
void process_message(); void process_message();
void stop_queue(); void stop_queue();
pmt::pmt_t message;
void init(); void init();
void configure_gr_complex_gr_complex(); void configure_gr_complex_gr_complex();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
pmt::pmt_t message;
std::thread ch_thread;
size_t item_size; size_t item_size;
int nsamples; int nsamples;
bool stop{false};
}; };

View File

@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_test_nsamples, 1000000, "Number of samples to filter i
class NotchFilterTest : public ::testing::Test class NotchFilterTest : public ::testing::Test
{ {
protected: 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<Concurrent_Queue<pmt::pmt_t>>(); queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
config = std::make_shared<InMemoryConfiguration>(); config = std::make_shared<InMemoryConfiguration>();
} }
~NotchFilterTest() override = default;
bool stop = false;
std::thread ch_thread;
void start_queue(); void start_queue();
void wait_message(); void wait_message();
void process_message(); void process_message();
void stop_queue(); void stop_queue();
pmt::pmt_t message;
void init(); void init();
void configure_gr_complex_gr_complex(); void configure_gr_complex_gr_complex();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
std::thread ch_thread;
pmt::pmt_t message;
size_t item_size; size_t item_size;
int nsamples; int nsamples;
bool stop{false};
}; };

View File

@ -43,26 +43,28 @@ DEFINE_int32(pb_filter_test_nsamples, 1000000, "Number of samples to filter in t
class PulseBlankingFilterTest : public ::testing::Test class PulseBlankingFilterTest : public ::testing::Test
{ {
protected: 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<Concurrent_Queue<pmt::pmt_t>>(); queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
config = std::make_shared<InMemoryConfiguration>(); config = std::make_shared<InMemoryConfiguration>();
} }
~PulseBlankingFilterTest() override = default;
bool stop = false;
std::thread ch_thread;
void start_queue(); void start_queue();
void wait_message(); void wait_message();
void process_message(); void process_message();
void stop_queue(); void stop_queue();
void init(); void init();
void configure_gr_complex_gr_complex(); void configure_gr_complex_gr_complex();
std::thread ch_thread;
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
gr::top_block_sptr top_block;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
gr::top_block_sptr top_block;
pmt::pmt_t message;
size_t item_size; size_t item_size;
int nsamples; int nsamples;
pmt::pmt_t message; bool stop{false};
}; };

View File

@ -126,14 +126,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime)
// create the concurrent correlator threads // create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++) 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], correlator_pool[current_thread],
d_rem_carrier_phase_rad, d_rem_carrier_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_step_rad,
d_code_phase_step_chips, d_code_phase_step_chips,
d_code_phase_rate_step_chips, d_code_phase_rate_step_chips,
d_rem_code_phase_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 // wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool) for (auto& t : thread_pool)
@ -224,14 +224,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTimeAlloc)
// create the concurrent correlator threads // create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++) 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], correlator_pool[current_thread],
d_rem_carrier_phase_rad, d_rem_carrier_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_step_rad,
d_code_phase_step_chips, d_code_phase_step_chips,
d_code_phase_rate_step_chips, d_code_phase_rate_step_chips,
d_rem_code_phase_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 // wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool) for (auto& t : thread_pool)

View File

@ -122,13 +122,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
// create the concurrent correlator threads // create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++) 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], correlator_pool[current_thread],
d_rem_carrier_phase_rad, d_rem_carrier_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_step_rad,
d_code_phase_step_chips, d_code_phase_step_chips,
d_rem_code_phase_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 // wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool) for (auto& t : thread_pool)
@ -220,13 +220,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTimeAlloc)
// create the concurrent correlator threads // create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++) 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], correlator_pool[current_thread],
d_rem_carrier_phase_rad, d_rem_carrier_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_step_rad,
d_code_phase_step_chips, d_code_phase_step_chips,
d_rem_code_phase_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 // wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool) for (auto& t : thread_pool)

View File

@ -45,11 +45,8 @@ protected:
{ {
factory = std::make_shared<GNSSBlockFactory>(); factory = std::make_shared<GNSSBlockFactory>();
config = std::make_shared<InMemoryConfiguration>(); config = std::make_shared<InMemoryConfiguration>();
gnss_synchro = Gnss_Synchro();
} }
~GalileoE1DllPllVemlTrackingInternalTest() override = default;
void init(); void init();
std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue; std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue;
@ -58,8 +55,8 @@ protected:
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro{}; Gnss_Synchro gnss_synchro{};
size_t item_size; size_t item_size;
bool stop{false};
int message{0}; int message{0};
bool stop{false};
}; };