1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 19:50:34 +00:00

Fix performance inefficiencies detected by Coverity Scan

This commit is contained in:
Carles Fernandez 2023-11-29 21:34:59 +01:00
parent 1818c88983
commit 4a8c58f6ba
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
10 changed files with 37 additions and 37 deletions

View File

@ -768,7 +768,7 @@ int hybrid_observables_gs::general_work(int noutput_items __attribute__((unused)
{ {
n_valid++; n_valid++;
} }
epoch_data[n] = interpolated_gnss_synchro; epoch_data[n] = std::move(interpolated_gnss_synchro);
} }
if (d_T_rx_TOW_set) if (d_T_rx_TOW_set)
{ {

View File

@ -44,7 +44,7 @@ bool Tlm_CRC_Stats::set_channel(int32_t channel)
{ {
std::string dump_filename_ = d_dump_crc_stats_filename.substr(d_dump_crc_stats_filename.find_last_of('/') + 1); std::string dump_filename_ = d_dump_crc_stats_filename.substr(d_dump_crc_stats_filename.find_last_of('/') + 1);
dump_path = d_dump_crc_stats_filename.substr(0, d_dump_crc_stats_filename.find_last_of('/')); dump_path = d_dump_crc_stats_filename.substr(0, d_dump_crc_stats_filename.find_last_of('/'));
d_dump_crc_stats_filename = dump_filename_; d_dump_crc_stats_filename = std::move(dump_filename_);
} }
else else
{ {

View File

@ -2075,7 +2075,7 @@ int kf_tracking::general_work(int noutput_items __attribute__((unused)), gr_vect
{ {
current_synchro_data.fs = static_cast<int64_t>(d_trk_parameters.fs_in); current_synchro_data.fs = static_cast<int64_t>(d_trk_parameters.fs_in);
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
*out[0] = current_synchro_data; *out[0] = std::move(current_synchro_data);
return 1; return 1;
} }
return 0; return 0;

View File

@ -29,7 +29,7 @@
*/ */
#include "bayesian_estimation.h" #include "bayesian_estimation.h"
#include <utility>
Bayesian_estimator::Bayesian_estimator() Bayesian_estimator::Bayesian_estimator()
: kappa_prior(0), : kappa_prior(0),
@ -122,10 +122,10 @@ void Bayesian_estimator::update_sequential(const arma::vec& data)
Psi_est = Psi_posterior / (nu_posterior + ny + 1); Psi_est = Psi_posterior / (nu_posterior + ny + 1);
} }
mu_prior = mu_posterior; mu_prior = std::move(mu_posterior);
kappa_prior = kappa_posterior; kappa_prior = kappa_posterior;
nu_prior = nu_posterior; nu_prior = nu_posterior;
Psi_prior = Psi_posterior; Psi_prior = std::move(Psi_posterior);
} }
@ -161,10 +161,10 @@ void Bayesian_estimator::update_sequential(const arma::vec& data, const arma::ve
Psi_est = Psi_posterior / (nu_posterior + ny + 1); Psi_est = Psi_posterior / (nu_posterior + ny + 1);
} }
mu_prior = mu_posterior; mu_prior = std::move(mu_posterior);
kappa_prior = kappa_posterior; kappa_prior = kappa_posterior;
nu_prior = nu_posterior; nu_prior = nu_posterior;
Psi_prior = Psi_posterior; Psi_prior = std::move(Psi_posterior);
} }

View File

@ -104,8 +104,8 @@ void CubatureFilter::predict_sequential(const arma::vec& x_post, const arma::mat
P_x_pred = P_x_pred / static_cast<float>(np) - x_pred * x_pred.t() + noise_covariance; P_x_pred = P_x_pred / static_cast<float>(np) - x_pred * x_pred.t() + noise_covariance;
// Store predicted mean and error covariance // Store predicted mean and error covariance
x_pred_out = x_pred; x_pred_out = std::move(x_pred);
P_x_pred_out = P_x_pred; P_x_pred_out = std::move(P_x_pred);
} }
@ -270,8 +270,8 @@ void UnscentedFilter::predict_sequential(const arma::vec& x_post, const arma::ma
P_x_pred = P_x_pred + noise_covariance; P_x_pred = P_x_pred + noise_covariance;
// Store predicted mean and error covariance // Store predicted mean and error covariance
x_pred_out = x_pred; x_pred_out = std::move(x_pred);
P_x_pred_out = P_x_pred; P_x_pred_out = std::move(P_x_pred);
} }

View File

@ -73,7 +73,7 @@ public:
{ {
observables.Clear(); observables.Clear();
std::string data; std::string data;
for (auto gs : vgs) for (const auto& gs : vgs)
{ {
gnss_sdr::GnssSynchro* obs = observables.add_observable(); gnss_sdr::GnssSynchro* obs = observables.add_observable();
char c = gs.System; char c = gs.System;

View File

@ -95,7 +95,7 @@ int64_t FileConfiguration::property(std::string property_name, int64_t default_v
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
@ -106,7 +106,7 @@ uint64_t FileConfiguration::property(std::string property_name, uint64_t default
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
@ -117,7 +117,7 @@ int FileConfiguration::property(std::string property_name, int default_value) co
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
@ -128,7 +128,7 @@ unsigned int FileConfiguration::property(std::string property_name, unsigned int
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
@ -161,7 +161,7 @@ float FileConfiguration::property(std::string property_name, float default_value
return overrided_->property(property_name, default_value); return overrided_->property(property_name, default_value);
} }
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
@ -178,7 +178,7 @@ double FileConfiguration::property(std::string property_name, double default_val
void FileConfiguration::set_property(std::string property_name, std::string value) void FileConfiguration::set_property(std::string property_name, std::string value)
{ {
overrided_->set_property(property_name, value); overrided_->set_property(std::move(property_name), std::move(value));
} }

View File

@ -192,16 +192,16 @@ auto const item_prop = ".item_type"s; // "item_type" property
template <typename To, typename From> template <typename To, typename From>
std::unique_ptr<To> dynamic_unique_cast(std::unique_ptr<From>&& p) std::unique_ptr<To> dynamic_unique_cast(std::unique_ptr<From>&& p)
{ {
std::unique_ptr<To> result;
if (To* cast = dynamic_cast<To*>(p.get())) if (To* cast = dynamic_cast<To*>(p.get()))
{ {
result.reset(cast); std::unique_ptr<To> result(cast);
p.release(); // NOLINT(bugprone-unused-return-value) p.release(); // NOLINT(bugprone-unused-return-value)
return result;
} }
return result; return std::unique_ptr<To>(nullptr);
} }
auto findRole(ConfigurationInterface const* configuration, std::string const& base, int ID) -> std::string auto findRole(ConfigurationInterface const* configuration, std::string const& base, int ID) -> std::string
{ {
auto role = base + std::to_string(ID); auto role = base + std::to_string(ID);

View File

@ -2190,7 +2190,7 @@ void GNSSFlowgraph::set_signals_list()
if (!tmp_set.empty()) if (!tmp_set.empty())
{ {
available_galileo_prn = tmp_set; available_galileo_prn = std::move(tmp_set);
} }
} }
@ -2230,7 +2230,7 @@ void GNSSFlowgraph::set_signals_list()
if (!tmp_set.empty()) if (!tmp_set.empty())
{ {
available_gps_prn = tmp_set; available_gps_prn = std::move(tmp_set);
} }
} }
@ -2270,7 +2270,7 @@ void GNSSFlowgraph::set_signals_list()
if (!tmp_set.empty()) if (!tmp_set.empty())
{ {
available_sbas_prn = tmp_set; available_sbas_prn = std::move(tmp_set);
} }
} }
@ -2310,7 +2310,7 @@ void GNSSFlowgraph::set_signals_list()
if (!tmp_set.empty()) if (!tmp_set.empty())
{ {
available_glonass_prn = tmp_set; available_glonass_prn = std::move(tmp_set);
} }
} }
@ -2350,7 +2350,7 @@ void GNSSFlowgraph::set_signals_list()
if (!tmp_set.empty()) if (!tmp_set.empty())
{ {
available_beidou_prn = tmp_set; available_beidou_prn = std::move(tmp_set);
} }
} }

View File

@ -47,63 +47,63 @@ std::string InMemoryConfiguration::property(std::string property_name, std::stri
bool InMemoryConfiguration::property(std::string property_name, bool default_value) const bool InMemoryConfiguration::property(std::string property_name, bool default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
int64_t InMemoryConfiguration::property(std::string property_name, int64_t default_value) const int64_t InMemoryConfiguration::property(std::string property_name, int64_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
uint64_t InMemoryConfiguration::property(std::string property_name, uint64_t default_value) const uint64_t InMemoryConfiguration::property(std::string property_name, uint64_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
int32_t InMemoryConfiguration::property(std::string property_name, int32_t default_value) const int32_t InMemoryConfiguration::property(std::string property_name, int32_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
uint32_t InMemoryConfiguration::property(std::string property_name, uint32_t default_value) const uint32_t InMemoryConfiguration::property(std::string property_name, uint32_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
uint16_t InMemoryConfiguration::property(std::string property_name, uint16_t default_value) const uint16_t InMemoryConfiguration::property(std::string property_name, uint16_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
int16_t InMemoryConfiguration::property(std::string property_name, int16_t default_value) const int16_t InMemoryConfiguration::property(std::string property_name, int16_t default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
float InMemoryConfiguration::property(std::string property_name, float default_value) const float InMemoryConfiguration::property(std::string property_name, float default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }
double InMemoryConfiguration::property(std::string property_name, double default_value) const double InMemoryConfiguration::property(std::string property_name, double default_value) const
{ {
const std::string empty; const std::string empty;
return converter_->convert(property(property_name, empty), default_value); return converter_->convert(property(std::move(property_name), empty), default_value);
} }