mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 01:27:38 +01:00
#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:
parent
39a80e414e
commit
d49e97c423
@ -116,7 +116,7 @@ class LibraryLoader
|
||||
} );
|
||||
}
|
||||
|
||||
URLClassLoader loader = new URLClassLoader( jarFiles.toArray( new URL[ jarFiles.size() ] ) );
|
||||
URLClassLoader loader = new URLClassLoader( jarFiles.toArray( new URL[ 0 ] ) );
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ public final class ChatColor
|
||||
@Deprecated
|
||||
public static ChatColor[] values()
|
||||
{
|
||||
return BY_CHAR.values().toArray( new ChatColor[ BY_CHAR.values().size() ] );
|
||||
return BY_CHAR.values().toArray( new ChatColor[ 0 ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ public final class ComponentBuilder
|
||||
*/
|
||||
public ComponentBuilder(ComponentBuilder original)
|
||||
{
|
||||
this( original.parts.toArray( new BaseComponent[ original.parts.size() ] ) );
|
||||
this( original.parts.toArray( new BaseComponent[ 0 ] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ public final class TextComponent extends BaseComponent
|
||||
component.setText( builder.toString() );
|
||||
components.add( component );
|
||||
|
||||
return components.toArray( new BaseComponent[ components.size() ] );
|
||||
return components.toArray( new BaseComponent[ 0 ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 );
|
||||
|
@ -115,7 +115,7 @@ public final class ChatComponentTransformer
|
||||
{
|
||||
if ( root.getExtra() != null && !root.getExtra().isEmpty() )
|
||||
{
|
||||
List<BaseComponent> list = Lists.newArrayList( transform( player, transformHover, root.getExtra().toArray( new BaseComponent[ root.getExtra().size() ] ) ) );
|
||||
List<BaseComponent> list = Lists.newArrayList( transform( player, transformHover, root.getExtra().toArray( new BaseComponent[ 0 ] ) ) );
|
||||
root.setExtra( list );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user