← Back to team overview

kicad-developers team mailing list archive

[PATCH 05/16] Cache netlist item during ERC

 

This adds a suffix "_idx" to the indexes into the list, and introduces local
copies of the pointers to the objects we are looking at, in order to have a
shorter way of addressing them.
---
 eeschema/dialogs/dialog_erc.cpp | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp
index 7323a64..90ff1e9 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -492,8 +492,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
     // Reset the connection type indicator
     objectsConnectedList->ResetConnectionsType();
 
-    unsigned lastItem;
-    unsigned nextItem = lastItem = 0;
+    unsigned lastItem_idx;
+    unsigned nextItem_idx = lastItem_idx = 0;
     int MinConn    = NOC;
 
     /** The netlist generated by SCH_EDIT_FRAME::BuildNetListBase is sorted
@@ -505,17 +505,19 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
      * pass.
      */
 
-    for( unsigned item = 0; item < objectsConnectedList->size(); item++ )
+    for( unsigned item_idx = 0; item_idx < objectsConnectedList->size(); item_idx++ )
     {
-        if( objectsConnectedList->GetItemNet( lastItem ) !=
-            objectsConnectedList->GetItemNet( item ) )
+        auto item = objectsConnectedList->GetItem( item_idx );
+        auto lastItem = objectsConnectedList->GetItem( lastItem_idx );
+
+        if( lastItem->GetNet() != item->GetNet() )
         {
             // New net found:
-            MinConn    = NOC;
-            nextItem   = item;
+            MinConn      = NOC;
+            nextItem_idx = item_idx;
         }
 
-        switch( objectsConnectedList->GetItemType( item ) )
+        switch( item->m_Type )
         {
         // These items do not create erc problems
         case NET_ITEM_UNSPECIFIED:
@@ -535,11 +537,11 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
             // ERC problems when pin sheets do not match hierarchical labels.
             // Each pin sheet must match a hierarchical label
             // Each hierarchical label must match a pin sheet
-            objectsConnectedList->TestforNonOrphanLabel( item, nextItem );
+            objectsConnectedList->TestforNonOrphanLabel( item_idx, nextItem_idx );
             break;
         case NET_GLOBLABEL:
             if( m_tstUniqueGlobalLabels )
-                objectsConnectedList->TestforNonOrphanLabel( item, nextItem );
+                objectsConnectedList->TestforNonOrphanLabel( item_idx, nextItem_idx );
             break;
 
         case NET_NOCONNECT:
@@ -547,19 +549,19 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
             // ERC problems when a noconnect symbol is connected to more than one pin.
             MinConn = NET_NC;
 
-            if( objectsConnectedList->CountPinsInNet( nextItem ) > 1 )
-                Diagnose( objectsConnectedList->GetItem( item ), NULL, MinConn, UNC );
+            if( objectsConnectedList->CountPinsInNet( nextItem_idx ) > 1 )
+                Diagnose( item, NULL, MinConn, UNC );
 
             break;
 
         case NET_PIN:
 
             // Look for ERC problems between pins:
-            TestOthersItems( objectsConnectedList.get(), item, nextItem, &MinConn );
+            TestOthersItems( objectsConnectedList.get(), item_idx, nextItem_idx, &MinConn );
             break;
         }
 
-        lastItem = item;
+        lastItem_idx = item_idx;
     }
 
     // Test similar labels (i;e. labels which are identical when

Follow ups

References