Skip to content

Commit

Permalink
Refactor bad smells:
Browse files Browse the repository at this point in the history
- ToArrayCallWithZeroLengthArrayArgument
The performance of the empty array version is the same, and sometimes even better, compared
to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or
synchronized collection as a data race is possible between the <code>size</code> and <code>toArray</code>
calls. This may result in extra <code>null</code>s at the end of the array if the collection was concurrently
shrunk during the operation.</p>
See https://shipilev.net/blog/2016/arrays-wisdom-ancients/ for more details.
  • Loading branch information
MartinWitt authored and michael-o committed Apr 2, 2023
1 parent e27ac13 commit 34550ec
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private ReportPlugin[] getReportingPlugins() {
mpir.setArtifactId("maven-project-info-reports-plugin");
reportingPlugins.add(mpir);
}
return reportingPlugins.toArray(new ReportPlugin[reportingPlugins.size()]);
return reportingPlugins.toArray(new ReportPlugin[0]);
}

protected SiteRenderingContext createSiteRenderingContext(Locale locale)
Expand Down

0 comments on commit 34550ec

Please sign in to comment.