Eeschema: Simplify GetItem

Avoids calling HitTest on each item when it is not needed
This commit is contained in:
Seth Hillbrand 2017-10-26 09:53:17 -07:00
parent 8bb9084ea9
commit 62fe78f08c
1 changed files with 2 additions and 4 deletions

View File

@ -215,9 +215,6 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
{
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
{
if( item->HitTest( aPosition, aAccuracy ) && (aType == NOT_USED) )
return item;
if( (aType == SCH_FIELD_T) && (item->Type() == SCH_COMPONENT_T) )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
@ -239,7 +236,8 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
if( label )
return (SCH_ITEM*) label;
}
else if( (item->Type() == aType) && item->HitTest( aPosition, aAccuracy ) )
else if( ( ( item->Type() == aType ) || ( aType == NOT_USED ) )
&& item->HitTest( aPosition, aAccuracy ) )
{
return item;
}