some micro optimisations in SearchEventTable
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6707 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -797,35 +797,40 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
|
|||||||
|
|
||||||
bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
|
bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
|
||||||
{
|
{
|
||||||
int i = 0;
|
wxEventType eventType = event.GetEventType();
|
||||||
int commandId = event.GetId();
|
int eventId = event.GetId();
|
||||||
|
|
||||||
// BC++ doesn't like while (table.entries[i].m_fn)
|
// BC++ doesn't like testing for m_fn without != 0
|
||||||
|
for ( int i = 0; table.entries[i].m_fn != 0; i++ )
|
||||||
#ifdef __SC__
|
|
||||||
while (table.entries[i].m_fn != 0)
|
|
||||||
#else
|
|
||||||
while (table.entries[i].m_fn != 0L)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if ((event.GetEventType() == table.entries[i].m_eventType) &&
|
const wxEventTableEntry& entry = table.entries[i];
|
||||||
(table.entries[i].m_id == -1 || // Match, if event spec says any id will do (id == -1)
|
|
||||||
(table.entries[i].m_lastId == -1 && commandId == table.entries[i].m_id) ||
|
// match only if the event type is the same and the id is either -1 in
|
||||||
(table.entries[i].m_lastId != -1 &&
|
// the event table (meaning "any") or the event id matches the id
|
||||||
(commandId >= table.entries[i].m_id && commandId <= table.entries[i].m_lastId))))
|
// specified in the event table either exactly or by falling into
|
||||||
|
// range between first and last
|
||||||
|
if ( eventType == entry.m_eventType )
|
||||||
{
|
{
|
||||||
event.Skip(FALSE);
|
int tableId1 = entry.m_id,
|
||||||
event.m_callbackUserData = table.entries[i].m_callbackUserData;
|
tableId2 = entry.m_lastId;
|
||||||
|
|
||||||
(this->*((wxEventFunction) (table.entries[i].m_fn)))(event);
|
if ( (tableId1 == -1) ||
|
||||||
|
(tableId2 == -1 && eventId == tableId1) ||
|
||||||
|
(tableId2 != -1 &&
|
||||||
|
(eventId >= tableId1 && eventId <= tableId2)) )
|
||||||
|
{
|
||||||
|
event.Skip(FALSE);
|
||||||
|
event.m_callbackUserData = entry.m_callbackUserData;
|
||||||
|
|
||||||
if ( event.GetSkipped() )
|
(this->*((wxEventFunction) (entry.m_fn)))(event);
|
||||||
return FALSE;
|
|
||||||
else
|
return !event.GetSkipped();
|
||||||
return TRUE;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user