uhd: Use reference type to prevent copy

Thanks to mait for the fixes!
This commit is contained in:
A. Maitland Bottoms 2021-10-21 09:16:29 -05:00 committed by michael-west
parent a5f32a71c5
commit e35f66e82f
8 changed files with 8 additions and 8 deletions

View file

@ -56,7 +56,7 @@ public:
{
std::lock_guard<std::mutex> lock(_mutex);
for (auto const event_handler : _event_handlers) {
for (const auto& event_handler : _event_handlers) {
// If the event code in the message matches the event code used at
// registration time, call the event handler
if ((metadata.event_code & event_handler.first) == event_handler.first) {

View file

@ -32,7 +32,7 @@ std::vector<size_t> sink_block_ctrl_base::get_input_ports() const
{
std::vector<size_t> input_ports;
input_ports.reserve(_tree->list(_root_path / "ports" / "in").size());
for (const std::string port : _tree->list(_root_path / "ports" / "in")) {
for (const std::string& port : _tree->list(_root_path / "ports" / "in")) {
input_ports.push_back(boost::lexical_cast<size_t>(port));
}
return input_ports;

View file

@ -64,7 +64,7 @@ std::vector<size_t> source_block_ctrl_base::get_output_ports() const
{
std::vector<size_t> output_ports;
output_ports.reserve(_tree->list(_root_path / "ports" / "out").size());
for (const std::string port : _tree->list(_root_path / "ports" / "out")) {
for (const std::string& port : _tree->list(_root_path / "ports" / "out")) {
output_ports.push_back(boost::lexical_cast<size_t>(port));
}
return output_ports;

View file

@ -742,7 +742,7 @@ b200_impl::b200_impl(
////////////////////////////////////////////////////////////////////
_radio_perifs[0].fp_gpio =
gpio_atr_3000::make(_radio_perifs[0].ctrl, TOREG(SR_FP_GPIO), RB32_FP_GPIO);
for (const gpio_attr_map_t::value_type attr : gpio_attr_map) {
for (const gpio_attr_map_t::value_type& attr : gpio_attr_map) {
switch (attr.first) {
case usrp::gpio_atr::GPIO_SRC:
_tree

View file

@ -156,7 +156,7 @@ static const boost::array<double, 17> tvrx_gains_volts = {{0.8,
static uhd::dict<std::string, gain_range_t> 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

View file

@ -426,7 +426,7 @@ void n230_impl::_initialize_property_tree(const fs_path& mb_path)
//------------------------------------------------------------------
// MiniSAS GPIO
//------------------------------------------------------------------
for (const usrp::gpio_atr::gpio_attr_map_t::value_type attr :
for (const usrp::gpio_atr::gpio_attr_map_t::value_type& attr :
usrp::gpio_atr::gpio_attr_map) {
switch (attr.first) {
case usrp::gpio_atr::GPIO_SRC:

View file

@ -93,7 +93,7 @@ UHD_RFNOC_RADIO_BLOCK_CONSTRUCTOR(x300_radio_ctrl)
if (_radio_type == PRIMARY) {
_fp_gpio = gpio_atr::gpio_atr_3000::make(
ctrl, regs::sr_addr(regs::FP_GPIO), regs::rb_addr(regs::RB_FP_GPIO));
for (const gpio_atr::gpio_attr_map_t::value_type attr : gpio_atr::gpio_attr_map) {
for (const gpio_atr::gpio_attr_map_t::value_type& attr : gpio_atr::gpio_attr_map) {
switch (attr.first) {
case usrp::gpio_atr::GPIO_SRC:
_tree

View file

@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(test_lookup)
{0x5CC0000000000000, "SchmidlCox"}};
std::cout << blocknames.size() << std::endl;
for (const auto block : blocknames) {
for (const auto& block : blocknames) {
std::cout << "Testing " << block.second << " => "
<< str(boost::format("%016X") % block.first) << std::endl;
auto block_definition = blockdef::make_from_noc_id(block.first);