aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2013-04-03 23:30:53 -0700
committerHarvey Harrison <[email protected]>2013-04-03 23:30:53 -0700
commitd70f55e63c38331486249bdfdbd1234ce4bbeb09 (patch)
treec9b3bb6b33ada57aabaf1e6d9e3729daa05ec88a /src
parentbdbba7ca4ae73c3212a46318dab83731706c4e3e (diff)
gluegen: use explicit ArrayList constructor to avoid @SuppressWarnings and clone()
ArrayList.clone does _not_ make a shallow copy, a new internal array is allocated. As such, there is nearly no benefit to using clone(). Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/common/util/ArrayHashSet.java6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java
index 0f5f65b..630e2af 100644
--- a/src/java/com/jogamp/common/util/ArrayHashSet.java
+++ b/src/java/com/jogamp/common/util/ArrayHashSet.java
@@ -94,8 +94,7 @@ public class ArrayHashSet<E>
* @return a shallow copy of this ArrayHashSet, elements are not copied.
*/
public final Object clone() {
- @SuppressWarnings("unchecked")
- ArrayList<E> clonedList = (ArrayList<E>)data.clone();
+ ArrayList<E> clonedList = new ArrayList<E>(data);
ArrayHashSet<E> newObj = new ArrayHashSet<E>();
newObj.addAll(clonedList);
@@ -375,9 +374,8 @@ public class ArrayHashSet<E>
/**
* @return a shallow copy of this ArrayHashSet's ArrayList, elements are not copied.
*/
- @SuppressWarnings("unchecked")
public final ArrayList<E> toArrayList() {
- return (ArrayList<E>) data.clone();
+ return new ArrayList<E>(data);
}
/**