From 2409bcbc7c9606b055e23f52d688eecda84351d6 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 15 Aug 2020 16:33:00 +0200 Subject: Redundant Collection.addAll() call Reports Collection.addAll() and Map.putAll() calls after instantiation of a collection using a constructor call without arguments. Such constructs can be replaced with a single call to a parametrized constructor which simplifies code. Also for some collections the replacement might be more performant. Signed-off-by: Lars Grefer --- taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java | 3 +-- .../src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'taskdefs/src') diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index 83dcd9911..c6ebb14b3 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -1159,7 +1159,6 @@ public class AjcTask extends MatchingTask { // package-private for testing String[] makeCommand() { - ArrayList result = new ArrayList(); if (0 < ignored.size()) { for (Object o : ignored) { logVerbose("ignored: " + o); @@ -1182,7 +1181,7 @@ public class AjcTask extends MatchingTask { outjarFixedup = true; } - result.addAll(cmd.extractArguments()); + ArrayList result = new ArrayList(cmd.extractArguments()); addListArgs(result); String[] command = (String[]) result.toArray(new String[0]); diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java index 25128bb61..43125a862 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/compilers/Ajc.java @@ -53,8 +53,7 @@ public class Ajc extends DefaultCompilerAdapter { "-encoding", "-target" }); private static List finalList(String[] args) { - List result = new ArrayList<>(); - result.addAll(Arrays.asList(args)); + List result = new ArrayList<>(Arrays.asList(args)); return Collections.unmodifiableList(result); } -- cgit v1.2.3