[groovy] branch master updated: Trivial refactoring: remove redundant 'Collection.addAll()' calls

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated: Trivial refactoring: remove redundant 'Collection.addAll()' calls

Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new bb52ea0  Trivial refactoring: remove redundant 'Collection.addAll()' calls
bb52ea0 is described below

commit bb52ea08a04966ffd18999acbdfa58cb81486864
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Dec 1 19:49:11 2019 +0800

    Trivial refactoring: remove redundant 'Collection.addAll()' calls
---
 .../runtime/metaclass/ConcurrentReaderHashMap.java     | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
index 1337b77..4ca393a 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
@@ -865,13 +865,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-        c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }
@@ -906,13 +904,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }
@@ -957,13 +953,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun