← Back to team overview

kicad-developers team mailing list archive

[PATCH 2/5] Schematic Cleanup: introduce shorthand for line/junction tests

 

---
 eeschema/sch_screen.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index bb3ebe1..fd9b9b2 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -432,7 +432,12 @@ bool SCH_SCREEN::SchematicCleanUp()
 
     for( SCH_ITEM* item = m_drawList.begin() ; item; item = item->Next() )
     {
-        if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
+        const auto lhs_type = item->Type();
+
+        const bool lhs_isLine = ( lhs_type == SCH_LINE_T );
+        const bool lhs_isJunction = (lhs_type == SCH_JUNCTION_T );
+
+        if( !( lhs_isLine || lhs_isJunction ) )
             continue;
 
         bool restart;
@@ -441,7 +446,7 @@ bool SCH_SCREEN::SchematicCleanUp()
         {
             restart = false;
 
-            if( ( item->Type() == SCH_LINE_T ) && ( testItem->Type() == SCH_LINE_T ) )
+            if( lhs_isLine && ( testItem->Type() == SCH_LINE_T ) )
             {
                 SCH_LINE* line = (SCH_LINE*) item;
 
@@ -454,7 +459,7 @@ bool SCH_SCREEN::SchematicCleanUp()
                     modified = true;
                 }
             }
-            else if ( ( ( item->Type() == SCH_JUNCTION_T )
+            else if ( ( lhs_isJunction
                       && ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
             {
                 if ( testItem->HitTest( item->GetPosition() ) )

Follow ups

References