From 47623aabb4832d3d217faa1a9938bb7a6e4341c3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 8 Jan 2021 13:23:17 +0100 Subject: lib: Use const-ref in for loops instead of const-copy This is potentially a performance issue, even though it doesn't have a big impact in this context. Clang will warn about it, and this fixes the compiler warning. --- host/lib/usrp/dboard/db_tvrx.cpp | 2 +- host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/dboard') diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index 02fed018c..c9a940d15 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -158,7 +158,7 @@ static const boost::array tvrx_gains_volts = {{0.8, static uhd::dict get_tvrx_gain_ranges(void) { double rfmax = 0.0, rfmin = FLT_MAX; - for (const std::string range : tvrx_rf_gains_db.keys()) { + for (const std::string& range : tvrx_rf_gains_db.keys()) { double my_max = tvrx_rf_gains_db[range].back(); // we're assuming it's monotonic double my_min = tvrx_rf_gains_db[range].front(); // if it's not this is wrong wrong wrong diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp index 82da7ec75..98c370275 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp @@ -227,7 +227,7 @@ void magnesium_radio_control_impl::_init_frontend_subtree( // TX gains std::vector tx_gain_names = get_tx_gain_names(chan_idx); tx_gain_names.push_back("all"); - for (const auto gain_name : tx_gain_names) { + for (const auto& gain_name : tx_gain_names) { subtree->create(tx_fe_path / "gains" / gain_name / "value") .set_coercer([this, chan_idx, gain_name](const double gain) { return this->set_tx_gain(gain, gain_name, chan_idx); @@ -256,7 +256,7 @@ void magnesium_radio_control_impl::_init_frontend_subtree( // RX gains std::vector rx_gain_names = get_rx_gain_names(chan_idx); rx_gain_names.push_back("all"); - for (const auto gain_name : rx_gain_names) { + for (const auto& gain_name : rx_gain_names) { subtree->create(rx_fe_path / "gains" / gain_name / "value") .set_coercer([this, chan_idx, gain_name](const double gain) { return this->set_rx_gain(gain, gain_name, chan_idx); -- cgit v1.2.3