Avoid claling FindToolByPositionWithPacking() needlessly

This is a micro-optimization after the previous commit: don't call
FindToolByPositionWithPacking() at all rather than calling it and then
ignoring its result if wxAUI_TB_NO_TOOLTIPS style is set.

This commit is best viewed ignoring whitespace.
This commit is contained in:
Vadim Zeitlin
2020-09-20 18:18:36 +02:00
parent 932b9ca62f
commit 466f72a16c

View File

@@ -2874,24 +2874,27 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt)
SetHoverItem(hitItem); SetHoverItem(hitItem);
// tooltips handling // tooltips handling
wxAuiToolBarItem* packingHitItem; if ( !HasFlag(wxAUI_TB_NO_TOOLTIPS) )
packingHitItem = FindToolByPositionWithPacking(evt.GetX(), evt.GetY());
if ( !HasFlag(wxAUI_TB_NO_TOOLTIPS) && packingHitItem )
{ {
if (packingHitItem != m_tipItem) wxAuiToolBarItem* packingHitItem;
packingHitItem = FindToolByPositionWithPacking(evt.GetX(), evt.GetY());
if ( packingHitItem )
{ {
m_tipItem = packingHitItem; if (packingHitItem != m_tipItem)
{
m_tipItem = packingHitItem;
if ( !packingHitItem->m_shortHelp.empty() ) if ( !packingHitItem->m_shortHelp.empty() )
SetToolTip(packingHitItem->m_shortHelp); SetToolTip(packingHitItem->m_shortHelp);
else else
UnsetToolTip(); UnsetToolTip();
}
}
else
{
UnsetToolTip();
m_tipItem = NULL;
} }
}
else
{
UnsetToolTip();
m_tipItem = NULL;
} }
// figure out the dropdown button state (are we hovering or pressing it?) // figure out the dropdown button state (are we hovering or pressing it?)