From b3ec9fe09c47f6089f3c4cf6788400f26f6f497f Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Tue, 19 Oct 2021 01:05:21 -0400
Subject: [PATCH] use reference type to prevent copying

---
 host/lib/rfnoc/async_msg_handler.cpp        | 2 +-
 host/lib/rfnoc/sink_block_ctrl_base.cpp     | 2 +-
 host/lib/rfnoc/source_block_ctrl_base.cpp   | 2 +-
 host/lib/usrp/b200/b200_impl.cpp            | 2 +-
 host/lib/usrp/dboard/db_tvrx.cpp            | 2 +-
 host/lib/usrp/n230/n230_impl.cpp            | 2 +-
 host/lib/usrp/x300/x300_radio_ctrl_impl.cpp | 2 +-
 host/tests/blockdef_test.cpp                | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

--- a/host/lib/rfnoc/async_msg_handler.cpp
+++ b/host/lib/rfnoc/async_msg_handler.cpp
@@ -56,7 +56,7 @@
     {
         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) {
--- a/host/lib/rfnoc/sink_block_ctrl_base.cpp
+++ b/host/lib/rfnoc/sink_block_ctrl_base.cpp
@@ -32,7 +32,7 @@
 {
     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;
--- a/host/lib/rfnoc/source_block_ctrl_base.cpp
+++ b/host/lib/rfnoc/source_block_ctrl_base.cpp
@@ -64,7 +64,7 @@
 {
     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;
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -745,7 +745,7 @@
     ////////////////////////////////////////////////////////////////////
     _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
--- a/host/lib/usrp/dboard/db_tvrx.cpp
+++ b/host/lib/usrp/dboard/db_tvrx.cpp
@@ -159,7 +159,7 @@
 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
--- a/host/lib/usrp/n230/n230_impl.cpp
+++ b/host/lib/usrp/n230/n230_impl.cpp
@@ -429,7 +429,7 @@
     //------------------------------------------------------------------
     // 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:
--- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp
@@ -96,7 +96,7 @@
     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
--- a/host/tests/blockdef_test.cpp
+++ b/host/tests/blockdef_test.cpp
@@ -24,7 +24,7 @@
         {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);
