Don't try to bake handlers when there are no more handlers. Remove them instead!

This commit is contained in:
Dabo Ross 2013-09-05 21:59:31 -07:00 committed by md_5
parent 07e330b005
commit d0e5ee4e09

View File

@ -176,6 +176,8 @@ public class EventBus
private void bakeHandlers(Class<?> eventClass) private void bakeHandlers(Class<?> eventClass)
{ {
Map<EventPriority, Map<Object, Method[]>> handlersByPriority = byListenerAndPriority.get( eventClass ); Map<EventPriority, Map<Object, Method[]>> handlersByPriority = byListenerAndPriority.get( eventClass );
if ( handlersByPriority != null )
{
List<EventHandlerMethod> handlersList = new ArrayList<>( handlersByPriority.size() * 2 ); List<EventHandlerMethod> handlersList = new ArrayList<>( handlersByPriority.size() * 2 );
for ( EventPriority value : EventPriority.values() ) for ( EventPriority value : EventPriority.values() )
{ {
@ -193,5 +195,9 @@ public class EventBus
} }
} }
byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) ); byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) );
} else
{
byEventBaked.put( eventClass, null );
}
} }
} }