Copilot commented on code in PR #589:
URL: https://github.com/apache/maven-war-plugin/pull/589#discussion_r2556057272
##########
src/main/java/org/apache/maven/plugins/war/Overlay.java:
##########
@@ -325,14 +325,12 @@ public int hashCode() {
private String[] parse(String s) {
final List<String> result = new ArrayList<>();
- if (s == null) {
- return result.toArray(new String[result.size()]);
- } else {
+ if (s != null) {
String[] tokens = s.split(",");
for (String token : tokens) {
result.add(token.trim());
}
- return result.toArray(new String[result.size()]);
}
+ return result.toArray(new String[result.size()]);
Review Comment:
The array initialization pattern `result.toArray(new String[result.size()])`
is outdated. Modern Java (since Java 6) optimizes `result.toArray(new
String[0])` to be as fast or faster than pre-sizing the array, and it's the
recommended pattern. Consider changing to `result.toArray(new String[0])`.
```suggestion
return result.toArray(new String[0]);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]