Fix optimization to not fetch all possible endpoints for non-connectable.

This commit is contained in:
Jeff Young 2021-09-24 20:08:42 +01:00
parent fad385785d
commit 7901d705ba
2 changed files with 38 additions and 30 deletions

View File

@ -590,36 +590,41 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList, bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
const SCH_SHEET_PATH* aPath ) const SCH_SHEET_PATH* aPath )
{ {
bool previousStartState = m_startIsDangling; if( IsConnectable() )
bool previousEndState = m_endIsDangling;
m_startIsDangling = m_endIsDangling = true;
for( DANGLING_END_ITEM item : aItemList )
{ {
if( item.GetItem() == this ) bool previousStartState = m_startIsDangling;
continue; bool previousEndState = m_endIsDangling;
if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END ) m_startIsDangling = m_endIsDangling = true;
|| ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
for( DANGLING_END_ITEM item : aItemList )
{ {
if( m_start == item.GetPosition() ) if( item.GetItem() == this )
m_startIsDangling = false; continue;
if( m_end == item.GetPosition() ) if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
m_endIsDangling = false; || ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
{
if( m_start == item.GetPosition() )
m_startIsDangling = false;
if( !m_startIsDangling && !m_endIsDangling ) if( m_end == item.GetPosition() )
break; m_endIsDangling = false;
if( !m_startIsDangling && !m_endIsDangling )
break;
}
} }
// We only use the bus dangling state for automatic line starting, so we don't care if it
// has changed or not (and returning true will result in extra work)
if( IsBus() )
return false;
return previousStartState != m_startIsDangling || previousEndState != m_endIsDangling;
} }
// We only use the bus dangling state for automatic line starting, so we don't care if it return false;
// has changed or not (and returning true will result in extra work)
if( IsBus() )
return false;
else
return previousStartState != m_startIsDangling || previousEndState != m_endIsDangling;
} }

View File

@ -982,15 +982,18 @@ void SCH_SCREEN::TestDanglingEnds( const SCH_SHEET_PATH* aPath,
for( SCH_ITEM* item : Items() ) for( SCH_ITEM* item : Items() )
{ {
endPoints.clear(); if( item->IsConnectable() )
for( SCH_ITEM* overlapping : Items().Overlapping( item->GetBoundingBox() ) )
overlapping->GetEndPoints( endPoints );
if( item->UpdateDanglingState( endPoints, aPath ) )
{ {
if( aChangedHandler ) endPoints.clear();
(*aChangedHandler)( item );
for( SCH_ITEM* overlapping : Items().Overlapping( item->GetBoundingBox() ) )
overlapping->GetEndPoints( endPoints );
if( item->UpdateDanglingState( endPoints, aPath ) )
{
if( aChangedHandler )
(*aChangedHandler)( item );
}
} }
} }
} }