From: Joel Holdsworth Date: Tue, 20 May 2014 18:21:06 +0000 (+0100) Subject: Replaced lengthy iterator types with the auto keyword X-Git-Tag: pulseview-0.3.0~614 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f46e495ef1db0a4e522462ac18260f2151fa2b89;p=pulseview.git Replaced lengthy iterator types with the auto keyword --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 44e474b9..13c40a35 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -42,8 +42,7 @@ Decoder::Decoder(const srd_decoder *const dec) : Decoder::~Decoder() { - for (map::const_iterator i = _options.begin(); - i != _options.end(); i++) + for (auto i = _options.begin(); i != _options.end(); i++) g_variant_unref((*i).second); } @@ -101,10 +100,7 @@ bool Decoder::have_required_probes() const set< shared_ptr > Decoder::get_data() { set< shared_ptr > data; - for(map >:: - const_iterator i = _probes.begin(); - i != _probes.end(); i++) - { + for(auto i = _probes.cbegin(); i != _probes.cend(); i++) { shared_ptr signal((*i).second); assert(signal); data.insert(signal->logic_data()); @@ -118,8 +114,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - for (map::const_iterator i = _options.begin(); - i != _options.end(); i++) + for (auto i = _options.cbegin(); i != _options.cend(); i++) { GVariant *const value = (*i).second; g_variant_ref(value); @@ -138,9 +133,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si GHashTable *const probes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - for(map >:: - const_iterator i = _probes.begin(); - i != _probes.end(); i++) + for(auto i = _probes.cbegin(); i != _probes.cend(); i++) { shared_ptr signal((*i).second); GVariant *const gvar = g_variant_new_int32( diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp index 87da27cf..299380c8 100644 --- a/pv/data/decode/rowdata.cpp +++ b/pv/data/decode/rowdata.cpp @@ -41,8 +41,7 @@ void RowData::get_annotation_subset( vector &dest, uint64_t start_sample, uint64_t end_sample) const { - for (vector::const_iterator i = _annotations.begin(); - i != _annotations.end(); i++) + for (auto i = _annotations.cbegin(); i != _annotations.cend(); i++) if ((*i).end_sample() > start_sample && (*i).start_sample() <= end_sample) dest.push_back(*i); diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index c3bf26d2..f82d3ecc 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -106,7 +106,7 @@ void DecoderStack::remove(int index) assert(index < (int)_stack.size()); // Find the decoder in the stack - list< shared_ptr >::iterator iter = _stack.begin(); + auto iter = _stack.begin(); for(int i = 0; i < index; i++, iter++) assert(iter != _stack.end()); @@ -159,8 +159,7 @@ void DecoderStack::get_annotation_subset( { lock_guard lock(_output_mutex); - std::map::const_iterator iter = - _rows.find(row); + const auto iter = _rows.find(row); if (iter != _rows.end()) (*iter).second.get_annotation_subset(dest, start_sample, end_sample); @@ -265,8 +264,7 @@ uint64_t DecoderStack::get_max_sample_count() const { uint64_t max_sample_count = 0; - for (map::const_iterator i = _rows.begin(); - i != _rows.end(); i++) + for (auto i = _rows.cbegin(); i != _rows.end(); i++) max_sample_count = max(max_sample_count, (*i).second.get_max_sample()); @@ -396,11 +394,10 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) const srd_decoder *const decc = pdata->pdo->di->decoder; assert(decc); - map::iterator row_iter = d->_rows.end(); + auto row_iter = d->_rows.end(); // Try looking up the sub-row of this class - const map, Row>::const_iterator r = - d->_class_rows.find(make_pair(decc, a.format())); + const auto r = d->_class_rows.find(make_pair(decc, a.format())); if (r != d->_class_rows.end()) row_iter = d->_rows.find((*r).second); else diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index fb487a81..7a986c5a 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -65,7 +65,7 @@ list< shared_ptr > DeviceManager::driver_scan( // Remove any device instances from this driver from the device // list. They will not be valid after the scan. - list< shared_ptr >::iterator i = _devices.begin(); + auto i = _devices.begin(); while (i != _devices.end()) { if ((*i)->dev_inst()->driver == driver) i = _devices.erase(i); diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index d5ab9c47..1dd8c507 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -92,8 +92,7 @@ shared_ptr Connect::get_selected_device() const Qt::UserRole).value(); assert(sdi); - std::map >:: - const_iterator iter = _device_map.find(sdi); + const auto iter = _device_map.find(sdi); assert(iter != _device_map.end()); return (*iter).second; diff --git a/pv/popups/probes.cpp b/pv/popups/probes.cpp index ca1a2fb6..8683ab24 100644 --- a/pv/popups/probes.cpp +++ b/pv/popups/probes.cpp @@ -83,8 +83,7 @@ Probes::Probes(SigSession &session, QWidget *parent) : const sr_channel *const probe = (const sr_channel*)p->data; assert(probe); - const map >:: - iterator iter = signal_map.find(probe); + const auto iter = signal_map.find(probe); assert(iter != signal_map.end()); group_sigs.push_back((*iter).second); diff --git a/pv/prop/binding/decoderoptions.cpp b/pv/prop/binding/decoderoptions.cpp index 063daf8e..6e0630c0 100644 --- a/pv/prop/binding/decoderoptions.cpp +++ b/pv/prop/binding/decoderoptions.cpp @@ -111,7 +111,7 @@ GVariant* DecoderOptions::getter(const char *id) // Get the value from the hash table if it is already present const map& options = _decoder->options(); - map::const_iterator iter = options.find(id); + const auto iter = options.find(id); if (iter != options.end()) val = (*iter).second; diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 5ba2e5da..6948ced1 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -290,10 +290,7 @@ vector< shared_ptr > SigSession::get_decode_signals() const void SigSession::remove_decode_signal(view::DecodeTrace *signal) { - for (vector< shared_ptr >::iterator i = - _decode_traces.begin(); - i != _decode_traces.end(); - i++) + for (auto i = _decode_traces.begin(); i != _decode_traces.end(); i++) if ((*i).get() == signal) { _decode_traces.erase(i); diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 085e0430..6d419f74 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -148,8 +148,7 @@ shared_ptr SamplingBar::get_selected_device() const index).value(); assert(sdi); - map >:: - const_iterator iter = _device_selector_map.find(sdi); + const auto iter = _device_selector_map.find(sdi); if (iter == _device_selector_map.end()) return shared_ptr(); diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 618de9a3..f8217510 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -303,8 +303,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) } else { - list< shared_ptr >::const_iterator iter = - stack.begin(); + auto iter = stack.cbegin(); for (int i = 0; i < (int)stack.size(); i++, iter++) { shared_ptr dec(*iter); create_decoder_form(i, dec, parent, form); @@ -592,9 +591,7 @@ QComboBox* DecodeTrace::create_probe_selector( const vector< shared_ptr > sigs = _session.get_signals(); assert(_decoder_stack); - const map >::const_iterator probe_iter = - dec->channels().find(pdch); + const auto probe_iter = dec->channels().find(pdch); QComboBox *selector = new QComboBox(parent); @@ -705,7 +702,7 @@ void DecodeTrace::on_show_hide_decoder(int index) const list< shared_ptr > stack(_decoder_stack->stack()); // Find the decoder in the stack - list< shared_ptr >::const_iterator iter = stack.begin(); + auto iter = stack.cbegin(); for(int i = 0; i < index; i++, iter++) assert(iter != stack.end()); diff --git a/pv/view/header.cpp b/pv/view/header.cpp index e7bfcbf0..a00efb14 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -223,9 +223,7 @@ void Header::mouseMoveEvent(QMouseEvent *event) const int delta = event->pos().y() - _mouse_down_point.y(); - for (std::list, - int> >::iterator i = _drag_traces.begin(); - i != _drag_traces.end(); i++) { + for (auto i = _drag_traces.begin(); i != _drag_traces.end(); i++) { const boost::shared_ptr trace((*i).first); if (trace) { const int y = (*i).second + delta; diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 0b442647..546743e3 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -155,9 +155,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) QLineF *const edge_lines = new QLineF[edge_count]; line = edge_lines; - for (vector::const_iterator i = - edges.begin() + 1; - i != edges.end() - 1; i++) { + for (auto i = edges.cbegin() + 1; i != edges.cend() - 1; i++) { const float x = ((*i).first / samples_per_pixel - pixels_offset) + left; *line++ = QLineF(x, high_offset, x, low_offset); @@ -188,8 +186,7 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines, { QLineF *line = lines; - for (vector::const_iterator i = - edges.begin(); i != (edges.end() - 1); i++) + for (auto i = edges.begin(); i != (edges.end() - 1); i++) if ((*i).second == level) { *line++ = QLineF( ((*i).first / samples_per_pixel - diff --git a/pv/view/view.cpp b/pv/view/view.cpp index d1174895..3d3b8eb2 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -232,7 +232,7 @@ vector< shared_ptr > View::get_traces() const vector< shared_ptr > traces(sigs.size()); #endif - vector< shared_ptr >::iterator i = traces.begin(); + auto i = traces.begin(); i = copy(sigs.begin(), sigs.end(), i); #ifdef ENABLE_DECODE i = copy(decode_sigs.begin(), decode_sigs.end(), i);