Use empty array for Collection.toArray()
MSALChanges new array creation with Collection#toArray(T[]) to use an empty array argument, which is better for performance.
According to the Collection#toArray(T[]) documentation:
If the collection fits in the specified array, it is returned therein.
However, although it's not intuitive, allocating a right-sized array ahead of time to pass to the API appears to be generally worse for performance according to benchmarking and JVM developers due to a number of implementation details in both Java and the virtual machine.
H2 achieved significant performance gains by switching to empty arrays instead pre-sized ones.
org. openrewrite. staticanalysis. ReplaceCollectionToArrayArgWithEmptyArraymod run . --recipe= org. openrewrite. staticanalysis. ReplaceCollectionToArrayArgWithEmptyArrayInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.