#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

@@ -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 ] );
}
/**

View File

@@ -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 ] ) );
}
/**

View File

@@ -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 ] );
}
/**