#3099: Improve toArray calls by using an empty array as parameter.

From Intellij IDEA inspections: Since late updates of OpenJDK 6 this call was intrinsified, making the performance of the empty array version the same and sometimes even better, compared to the pre-sized version.
This commit is contained in:
Janmm14
2021-05-27 22:23:43 +00:00
committed by GitHub
parent 39a80e414e
commit d49e97c423
6 changed files with 7 additions and 8 deletions

View File

@@ -117,8 +117,7 @@ public class EventBus
currentPriorityMap = new HashMap<>();
prioritiesMap.put( entry.getKey(), currentPriorityMap );
}
Method[] baked = new Method[ entry.getValue().size() ];
currentPriorityMap.put( listener, entry.getValue().toArray( baked ) );
currentPriorityMap.put( listener, entry.getValue().toArray( new Method[ 0 ] ) );
}
bakeHandlers( e.getKey() );
}
@@ -196,7 +195,7 @@ public class EventBus
}
}
} while ( value++ < Byte.MAX_VALUE );
byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) );
byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ 0 ] ) );
} else
{
byEventBaked.remove( eventClass );