aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2019-11-08 20:21:30 +0000
committerMichael Dickens <michael.dickens@ettus.com>2019-12-04 10:13:22 -0500
commit1b85d1a7875c8ae3491009225e5134ca5734ca2e (patch)
tree58d7431551e0914c9ea76ba6952ecedca340747c
parentUse 'const' on more member variables (diff)
downloadgnuradio-1b85d1a7875c8ae3491009225e5134ca5734ca2e.tar.xz
gnuradio-1b85d1a7875c8ae3491009225e5134ca5734ca2e.zip
Use C++11 ranged for and ranged insert instead of manual loops
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.cc6
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.cc6
-rw-r--r--gr-blocks/lib/file_meta_sink_impl.cc9
-rw-r--r--gr-blocks/lib/keep_one_in_n_impl.cc5
-rw-r--r--gr-blocks/lib/multiply_by_tag_value_cc_impl.cc10
-rw-r--r--gr-blocks/lib/skiphead_impl.cc7
-rw-r--r--gr-blocks/lib/tag_debug_impl.cc12
-rw-r--r--gr-blocks/lib/tag_debug_impl.h1
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.cc4
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.h1
-rw-r--r--gr-blocks/lib/test_tag_variable_rate_ff_impl.cc5
-rw-r--r--gr-blocks/lib/throttle_impl.cc7
-rw-r--r--gr-digital/lib/burst_shaper_impl.cc11
-rw-r--r--gr-digital/lib/pfb_clock_sync_ccf_impl.cc5
-rw-r--r--gr-fec/lib/fec_mtrx_impl.cc9
15 files changed, 38 insertions, 60 deletions
diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc
index 7b8693f45..6975f4f30 100644
--- a/gr-blocks/lib/annotator_1to1_impl.cc
+++ b/gr-blocks/lib/annotator_1to1_impl.cc
@@ -69,11 +69,7 @@ int annotator_1to1_impl::work(int noutput_items,
std::vector<tag_t> all_tags;
get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items);
-
- std::vector<tag_t>::iterator itr;
- for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- d_stored_tags.push_back(*itr);
- }
+ d_stored_tags.insert(d_stored_tags.end(), all_tags.begin(), all_tags.end());
}
// Storing the current noutput_items as the value to the "noutput_items" key
diff --git a/gr-blocks/lib/annotator_alltoall_impl.cc b/gr-blocks/lib/annotator_alltoall_impl.cc
index 7bb572345..c257c0cb9 100644
--- a/gr-blocks/lib/annotator_alltoall_impl.cc
+++ b/gr-blocks/lib/annotator_alltoall_impl.cc
@@ -70,11 +70,7 @@ int annotator_alltoall_impl::work(int noutput_items,
std::vector<tag_t> all_tags;
get_tags_in_range(all_tags, i, abs_N, end_N);
-
- std::vector<tag_t>::iterator itr;
- for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- d_stored_tags.push_back(*itr);
- }
+ d_stored_tags.insert(d_stored_tags.end(), all_tags.begin(), all_tags.end());
}
// Source ID and key for any tag that might get applied from this block
diff --git a/gr-blocks/lib/file_meta_sink_impl.cc b/gr-blocks/lib/file_meta_sink_impl.cc
index ed75f135c..e3ce72db9 100644
--- a/gr-blocks/lib/file_meta_sink_impl.cc
+++ b/gr-blocks/lib/file_meta_sink_impl.cc
@@ -391,9 +391,8 @@ int file_meta_sink_impl::work(int noutput_items,
std::vector<tag_t> all_tags;
get_tags_in_range(all_tags, 0, abs_N, end_N);
- std::vector<tag_t>::iterator itr;
- for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- int item_offset = (int)(itr->offset - abs_N);
+ for (const auto& tag : all_tags) {
+ int item_offset = (int)(tag.offset - abs_N);
// Write date to file up to the next tag location
while (nwritten < item_offset) {
@@ -419,11 +418,11 @@ int file_meta_sink_impl::work(int noutput_items,
if (d_total_seg_size > 0) {
update_last_header();
- update_header(itr->key, itr->value);
+ update_header(tag.key, tag.value);
write_and_update();
d_total_seg_size = 0;
} else {
- update_header(itr->key, itr->value);
+ update_header(tag.key, tag.value);
update_last_header();
}
}
diff --git a/gr-blocks/lib/keep_one_in_n_impl.cc b/gr-blocks/lib/keep_one_in_n_impl.cc
index 5c7e4b3a1..3dfe3c3ca 100644
--- a/gr-blocks/lib/keep_one_in_n_impl.cc
+++ b/gr-blocks/lib/keep_one_in_n_impl.cc
@@ -92,10 +92,9 @@ int keep_one_in_n_impl::general_work(int noutput_items,
// Because we have set TPP_DONT, we have to propagate the tags here manually.
// Adjustment of the tag sample value is done using the float d_decim_rate.
std::vector<tag_t> tags;
- std::vector<tag_t>::iterator t;
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + ni);
- for (t = tags.begin(); t != tags.end(); t++) {
- tag_t new_tag = *t;
+ for (const auto& tag : tags) {
+ tag_t new_tag = tag;
new_tag.offset *= d_decim_rate;
add_item_tag(0, new_tag);
}
diff --git a/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc b/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
index 9907106bc..785cb87a5 100644
--- a/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
+++ b/gr-blocks/lib/multiply_by_tag_value_cc_impl.cc
@@ -65,11 +65,9 @@ int multiply_by_tag_value_cc_impl::work(int noutput_items,
std::vector<tag_t> tags;
get_tags_in_window(tags, 0, 0, noutput_items, d_tag_key);
- std::vector<tag_t>::iterator itag = tags.begin();
-
int start = 0, end;
- while (itag != tags.end()) {
- end = itag->offset - nitems_read(0);
+ for (const auto& tag : tags) {
+ end = tag.offset - nitems_read(0);
end *= d_vlen;
// Multiply based on the current value of k from 'start' to 'end'
@@ -77,7 +75,7 @@ int multiply_by_tag_value_cc_impl::work(int noutput_items,
start = end;
// Extract new value of k
- pmt::pmt_t k = itag->value;
+ pmt::pmt_t k = tag.value;
if (pmt::is_complex(k)) {
d_k = pmt::to_complex(k);
} else if (pmt::is_number(k)) {
@@ -87,8 +85,6 @@ int multiply_by_tag_value_cc_impl::work(int noutput_items,
boost::format("Got key '%1%' with incompatible value of '%2%'") %
pmt::write_string(d_tag_key) % pmt::write_string(k));
}
-
- itag++;
}
volk_32fc_s32fc_multiply_32fc(
diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc
index ed6082c2d..6a34b7b5a 100644
--- a/gr-blocks/lib/skiphead_impl.cc
+++ b/gr-blocks/lib/skiphead_impl.cc
@@ -76,10 +76,9 @@ int skiphead_impl::general_work(int noutput_items,
else { // nothing left to skip. copy away
// Grab all tags in the window and shift their offsets appropriately
get_tags_in_window(d_tags, 0, ii, ninput_items);
- for (std::vector<tag_t>::iterator it = d_tags.begin(); it != d_tags.end();
- it++) {
- (*it).offset -= d_nitems_to_skip;
- add_item_tag(0, *it);
+ for (auto& tag : d_tags) {
+ tag.offset -= d_nitems_to_skip;
+ add_item_tag(0, tag);
}
int n_to_copy = ninput_items - ii;
if (n_to_copy > 0) {
diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc
index 82a06354e..f6550e0ba 100644
--- a/gr-blocks/lib/tag_debug_impl.cc
+++ b/gr-blocks/lib/tag_debug_impl.cc
@@ -111,15 +111,15 @@ int tag_debug_impl::work(int noutput_items,
if (d_display) {
sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i
<< std::setfill(' ') << std::endl;
- for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
- sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10)
+ for (const auto& tag : d_tags) {
+ sout << std::setw(10) << "Offset: " << tag.offset << std::setw(10)
<< "Source: "
- << (pmt::is_symbol(d_tags_itr->srcid)
- ? pmt::symbol_to_string(d_tags_itr->srcid)
+ << (pmt::is_symbol(tag.srcid)
+ ? pmt::symbol_to_string(tag.srcid)
: "n/a")
- << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key)
+ << std::setw(10) << "Key: " << pmt::symbol_to_string(tag.key)
<< std::setw(10) << "Value: ";
- sout << d_tags_itr->value << std::endl;
+ sout << tag.value << std::endl;
}
}
}
diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h
index 6546b4ad4..dfe9486a7 100644
--- a/gr-blocks/lib/tag_debug_impl.h
+++ b/gr-blocks/lib/tag_debug_impl.h
@@ -35,7 +35,6 @@ class tag_debug_impl : public tag_debug
private:
const std::string d_name;
std::vector<tag_t> d_tags;
- std::vector<tag_t>::iterator d_tags_itr;
bool d_display;
pmt::pmt_t d_filter;
gr::thread::mutex d_mutex;
diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
index 6411ad0c4..d5050614a 100644
--- a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
@@ -60,8 +60,8 @@ int tagged_stream_to_pdu_impl::work(int noutput_items,
// Grab tags, throw them into dict
get_tags_in_range(d_tags, 0, nitems_read(0), nitems_read(0) + ninput_items[0]);
d_pdu_meta = pmt::make_dict();
- for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) {
- d_pdu_meta = dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
+ for (const auto& tag : d_tags) {
+ d_pdu_meta = dict_add(d_pdu_meta, tag.key, tag.value);
}
// Grab data, throw into vector
diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h
index a6fbdc7fa..26fc36ea0 100644
--- a/gr-blocks/lib/tagged_stream_to_pdu_impl.h
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h
@@ -33,7 +33,6 @@ class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu
const pdu::vector_type d_type;
pmt::pmt_t d_pdu_meta;
pmt::pmt_t d_pdu_vector;
- std::vector<tag_t>::iterator d_tags_itr;
std::vector<tag_t> d_tags;
public:
diff --git a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
index 580bf0d19..7ffaa2e09 100644
--- a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
+++ b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
@@ -89,7 +89,6 @@ int test_tag_variable_rate_ff_impl::general_work(int noutput_items,
}
std::vector<tag_t> tags;
- std::vector<tag_t>::iterator itags;
int i = 0, j = 0;
while (i < ninput_items[0]) {
@@ -111,8 +110,8 @@ int test_tag_variable_rate_ff_impl::general_work(int noutput_items,
// Manage Tags
d_new_in = nitems_read(0) + i;
get_tags_in_range(tags, 0, d_old_in, d_new_in);
- for (itags = tags.begin(); itags != tags.end(); itags++) {
- tag_t new_tag = *itags;
+ for (const auto& tag : tags) {
+ tag_t new_tag = tag;
new_tag.offset = d_last_out;
add_item_tag(0, new_tag);
}
diff --git a/gr-blocks/lib/throttle_impl.cc b/gr-blocks/lib/throttle_impl.cc
index abc7a512d..7b2cc7fd6 100644
--- a/gr-blocks/lib/throttle_impl.cc
+++ b/gr-blocks/lib/throttle_impl.cc
@@ -80,10 +80,9 @@ int throttle_impl::work(int noutput_items,
uint64_t abs_N = nitems_read(0);
std::vector<tag_t> all_tags;
get_tags_in_range(all_tags, 0, abs_N, abs_N + noutput_items);
- std::vector<tag_t>::iterator itr;
- for (itr = all_tags.begin(); itr != all_tags.end(); itr++) {
- if (pmt::eq((*itr).key, throttle_rx_rate_pmt)) {
- double new_rate = pmt::to_double((*itr).value);
+ for (const auto& tag : all_tags) {
+ if (pmt::eq(tag.key, throttle_rx_rate_pmt)) {
+ double new_rate = pmt::to_double(tag.value);
set_sample_rate(new_rate);
}
}
diff --git a/gr-digital/lib/burst_shaper_impl.cc b/gr-digital/lib/burst_shaper_impl.cc
index 98456264a..d4fb7310d 100644
--- a/gr-digital/lib/burst_shaper_impl.cc
+++ b/gr-digital/lib/burst_shaper_impl.cc
@@ -324,16 +324,15 @@ void burst_shaper_impl<T>::propagate_tags(int in_offset,
tag_t temp_tag;
std::vector<tag_t> tags;
- std::vector<tag_t>::iterator it;
this->get_tags_in_range(tags, 0, abs_start, abs_end);
- for (it = tags.begin(); it != tags.end(); it++) {
- if (!pmt::equal(it->key, d_length_tag_key)) {
- if (skip && (it->offset == d_length_tag_offset))
+ for (const auto& tag : tags) {
+ if (!pmt::equal(tag.key, d_length_tag_key)) {
+ if (skip && (tag.offset == d_length_tag_offset))
continue;
- temp_tag = *it;
- temp_tag.offset = abs_offset + it->offset - abs_start;
+ temp_tag = tag;
+ temp_tag.offset = abs_offset + tag.offset - abs_start;
this->add_item_tag(0, temp_tag);
}
}
diff --git a/gr-digital/lib/pfb_clock_sync_ccf_impl.cc b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc
index 851a593be..103fac685 100644
--- a/gr-digital/lib/pfb_clock_sync_ccf_impl.cc
+++ b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc
@@ -416,11 +416,10 @@ int pfb_clock_sync_ccf_impl::general_work(int noutput_items,
// Manage Tags
std::vector<tag_t> xtags;
- std::vector<tag_t>::iterator itags;
d_new_in = nitems_read(0) + count + d_out_idx + d_sps;
get_tags_in_range(xtags, 0, d_old_in, d_new_in);
- for (itags = xtags.begin(); itags != xtags.end(); itags++) {
- tag_t new_tag = *itags;
+ for (const auto& tag : xtags) {
+ tag_t new_tag = tag;
// new_tag.offset = d_last_out + d_taps_per_filter/(2*d_sps) - 2;
new_tag.offset = d_last_out + d_taps_per_filter / 4 - 2;
add_item_tag(0, new_tag);
diff --git a/gr-fec/lib/fec_mtrx_impl.cc b/gr-fec/lib/fec_mtrx_impl.cc
index 10ed5f4f3..302928665 100644
--- a/gr-fec/lib/fec_mtrx_impl.cc
+++ b/gr-fec/lib/fec_mtrx_impl.cc
@@ -141,14 +141,13 @@ void write_matrix_to_file(const std::string filename, matrix_sptr M)
outputfile << (*std::max_element(colweights.begin(), colweights.end())) << " "
<< (*std::max_element(rowweights.begin(), rowweights.end())) << std::endl;
- std::vector<unsigned int>::iterator itr;
- for (itr = colweights.begin(); itr != colweights.end(); itr++) {
- outputfile << (*itr) << " ";
+ for (const auto& weight : colweights) {
+ outputfile << weight << " ";
}
outputfile << std::endl;
- for (itr = rowweights.begin(); itr != rowweights.end(); itr++) {
- outputfile << (*itr) << " ";
+ for (const auto& weight : rowweights) {
+ outputfile << weight << " ";
}
outputfile << std::endl;