From 2e66d80af8a36642c79bda91c895e86cdc45c2a7 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 5 Aug 2019 20:03:29 -0700 Subject: [PATCH] erc: Avoid casting between iterators The iterator for containers should always match the container type. Using auto here re-forces the match. --- eeschema/erc.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 1b9c3118a7..8c199c6272 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -770,18 +770,17 @@ void NETLIST_OBJECT_LIST::TestforSimilarLabels() // build global labels and compare std::set loc_labelList; - std::set::const_iterator it; - for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) + for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) { if( (*it)->IsLabelGlobal() ) loc_labelList.insert( *it ); } // compare global labels (same label names appears only once in list) - for( it = loc_labelList.begin(); it != loc_labelList.end(); ++it ) + for( auto it = loc_labelList.begin(); it != loc_labelList.end(); ++it ) { - std::set::const_iterator it_aux = it; + auto it_aux = it; for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux ) { @@ -802,48 +801,47 @@ void NETLIST_OBJECT_LIST::TestforSimilarLabels() // Build paths list std::set pathsList; - for( it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) + for( auto it = uniqueLabelList.begin(); it != uniqueLabelList.end(); ++it ) pathsList.insert( *it ); // Examine each label inside a sheet path: - for( it = pathsList.begin(); it != pathsList.end(); ++it ) + for( auto it = pathsList.begin(); it != pathsList.end(); ++it ) { loc_labelList.clear(); - std::set::const_iterator it_aux = uniqueLabelList.begin(); + auto it_uniq = uniqueLabelList.begin(); - for( ; it_aux != uniqueLabelList.end(); ++it_aux ) + for( ; it_uniq != uniqueLabelList.end(); ++it_uniq ) { - if( (*it)->m_SheetPath.Path() == (*it_aux)->m_SheetPath.Path() ) - loc_labelList.insert( *it_aux ); + if( ( *it )->m_SheetPath.Path() == ( *it_uniq )->m_SheetPath.Path() ) + loc_labelList.insert( *it_uniq ); } // at this point, loc_labelList contains labels of the current sheet path. // Detect similar labels (same label names appears only once in list) - std::set::const_iterator ref_it; - for( ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it ) + for( auto ref_it = loc_labelList.begin(); ref_it != loc_labelList.end(); ++ref_it ) { NETLIST_OBJECT* ref_item = *ref_it; - it_aux = ref_it; + auto it_aux = ref_it; for( ++it_aux; it_aux != loc_labelList.end(); ++it_aux ) { // global label versus global label was already examined. // here, at least one label must be local - if( ref_item->IsLabelGlobal() && (*it_aux)->IsLabelGlobal() ) + if( ref_item->IsLabelGlobal() && ( *it_aux )->IsLabelGlobal() ) continue; - if( ref_item->m_Label.CmpNoCase( (*it_aux)->m_Label ) == 0 ) + if( ref_item->m_Label.CmpNoCase( ( *it_aux )->m_Label ) == 0 ) { // Create new marker for ERC. int cntA = countIndenticalLabels( fullLabelList, ref_item ); int cntB = countIndenticalLabels( fullLabelList, *it_aux ); if( cntA <= cntB ) - SimilarLabelsDiagnose( ref_item, (*it_aux) ); + SimilarLabelsDiagnose( ref_item, ( *it_aux ) ); else - SimilarLabelsDiagnose( (*it_aux), ref_item ); + SimilarLabelsDiagnose( ( *it_aux ), ref_item ); } } }