aboutsummaryrefslogtreecommitdiffstats
path: root/weaver/src
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-15 16:33:00 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-15 16:36:00 +0200
commit2409bcbc7c9606b055e23f52d688eecda84351d6 (patch)
treee775e9d0e033ec563236c31623f66d023c40aac5 /weaver/src
parent3641f1626df6b9b1c11dd3f16b01a01495f4662d (diff)
downloadaspectj-2409bcbc7c9606b055e23f52d688eecda84351d6.tar.gz
aspectj-2409bcbc7c9606b055e23f52d688eecda84351d6.zip
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 <eclipse@larsgrefer.de>
Diffstat (limited to 'weaver/src')
-rw-r--r--weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java6
-rw-r--r--weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java3
-rw-r--r--weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java6
-rw-r--r--weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java6
4 files changed, 7 insertions, 14 deletions
diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
index 06735b523..edf7a0c48 100644
--- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -923,8 +923,7 @@ class BcelClassWeaver implements IClassWeaver {
return false; // nothing to do
}
- Set<DeclareAnnotation> unusedDecams = new HashSet<>();
- unusedDecams.addAll(decaMs);
+ Set<DeclareAnnotation> unusedDecams = new HashSet<>(decaMs);
// These methods may have been targeted with declare annotation. Example: ITD on an interface
// where the top most implementor gets a real method. The top most implementor method
@@ -1413,8 +1412,7 @@ class BcelClassWeaver implements IClassWeaver {
List<BcelField> fields = clazz.getFieldGens();
if (fields != null) {
- Set<DeclareAnnotation> unusedDecafs = new HashSet<>();
- unusedDecafs.addAll(decafs);
+ Set<DeclareAnnotation> unusedDecafs = new HashSet<>(decafs);
for (BcelField field : fields) {
if (!field.getName().startsWith(NameMangler.PREFIX)) {
// Single first pass
diff --git a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java
index 2c99ee29f..f9b020272 100644
--- a/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java
+++ b/weaver/src/test/java/org/aspectj/weaver/ReferenceTypeTestCase.java
@@ -599,8 +599,7 @@ public class ReferenceTypeTestCase extends TestCase {
// ReferenceType.r = 0;
long stime = System.nanoTime();
for (int j = 0; j < 10; j++) {
- List objects2 = new ArrayList();
- objects2.addAll(objects);
+ List objects2 = new ArrayList(objects);
PartialOrder.sort(objects2);
}
long etime = System.nanoTime();
diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java
index a9d1fe9b4..ea5037e2c 100644
--- a/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java
+++ b/weaver/src/test/java/org/aspectj/weaver/bcel/AroundWeaveTestCase.java
@@ -80,12 +80,10 @@ public class AroundWeaveTestCase extends WeaveTestCase {
private void aroundTestAndOthers(String outName, final boolean matchOnlyPrintln)
throws IOException
{
-
- List<ShadowMunger> l = new ArrayList<>();
- // the afterReturning was taken out to avoid circular advice dependency
+ // the afterReturning was taken out to avoid circular advice dependency
- l.addAll(makeAdviceAll("before", matchOnlyPrintln));
+ List<ShadowMunger> l = new ArrayList<>(makeAdviceAll("before", matchOnlyPrintln));
//l.addAll(makeAdviceAll("afterReturning", matchOnlyPrintln));
l.add(makeAroundMunger(matchOnlyPrintln));
diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
index 5181efcf6..ab15c2bd3 100644
--- a/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
+++ b/weaver/src/test/java/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
@@ -286,8 +286,7 @@ public class Java15PointcutExpressionTest extends TestCase {
tps[parameterNumber].getAnnotationPattern().toString();
// parameter type annotation checking
- Set<String> expected = new HashSet<>();
- expected.addAll(mpnv.getParameterTypeAnnotations());
+ Set<String> expected = new HashSet<>(mpnv.getParameterTypeAnnotations());
StringTokenizer st = new StringTokenizer(expectedParameterTypeAnnotations==null?"":expectedParameterTypeAnnotations);
while (st.hasMoreTokens()) {
@@ -305,8 +304,7 @@ public class Java15PointcutExpressionTest extends TestCase {
}
// parameter annotation checking
- expected = new HashSet<>();
- expected.addAll(mpnv.getParameterAnnotations());
+ expected = new HashSet<>(mpnv.getParameterAnnotations());
st = new StringTokenizer(expectedParameterAnnotations==null?"":expectedParameterAnnotations);
while (st.hasMoreTokens()) {