summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-08-16 11:31:04 +0200
committerSven Gothel <[email protected]>2014-08-16 11:31:04 +0200
commit6de8ace67b26f039fb1c89a3fce4d5f2437c615c (patch)
tree02da4909cf84dcd1d1c4712b7732ff4b78b1d8b4
parente2be0d00dcd28dc7d6b5df444e2ede80edd7cad5 (diff)
IntIntHashMap: Reduce temp. ArrayList<Entry> instances in clone
-rwxr-xr-xmake/scripts/runtest.sh4
-rw-r--r--src/java/com/jogamp/common/util/IntIntHashMap.java7
-rw-r--r--src/junit/com/jogamp/common/util/IntIntHashMapTest.java4
-rw-r--r--src/junit/com/jogamp/common/util/IntObjectHashMapTest.java4
-rw-r--r--src/junit/com/jogamp/common/util/LongIntHashMapTest.java4
5 files changed, 15 insertions, 8 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh
index ccdae48..a1f394c 100755
--- a/make/scripts/runtest.sh
+++ b/make/scripts/runtest.sh
@@ -92,7 +92,7 @@ function onetest() {
#onetest com.jogamp.common.util.TestFloatStack01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestIntegerStack01 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestArrayHashSet01 2>&1 | tee -a $LOG
-#onetest com.jogamp.common.util.IntIntHashMapTest 2>&1 | tee -a $LOG
+onetest com.jogamp.common.util.IntIntHashMapTest 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.IntObjectHashMapTest 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.LongIntHashMapTest 2>&1 | tee -a $LOG
#onetest com.jogamp.common.util.TestPlatform01 2>&1 | tee -a $LOG
@@ -121,7 +121,7 @@ function onetest() {
#onetest com.jogamp.common.os.TestElfReader01 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.PCPPTest 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG
-onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
+#onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.generation.Test1p2LoadJNIAndImplLib 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen01 2>&1 | tee -a $LOG
#onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen02 2>&1 | tee -a $LOG
diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java
index 954b379..f78b1e0 100644
--- a/src/java/com/jogamp/common/util/IntIntHashMap.java
+++ b/src/java/com/jogamp/common/util/IntIntHashMap.java
@@ -162,18 +162,19 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable,
mask, capacity, threshold,
keyNotFoundValue);
+ final ArrayList<Entry> entries = new ArrayList<Entry>();
for(int i=table.length-1; i>=0; i--) {
// single linked list -> ArrayList
- final ArrayList<Entry> entries = new ArrayList<Entry>();
Entry se = table[i];
while(null != se) {
entries.add(se);
se = se.next;
}
// clone ArrayList -> single linked list (bwd)
+ final int count = entries.size();
Entry de_next = null;
- for(int j=entries.size()-1; j>=0; j--) {
- se = entries.get(j);
+ for(int j=count-1; j>=0; j--) {
+ se = entries.remove(j);
if( isPrimitive ) {
de_next = new Entry(se.key, se.value, de_next);
} else {
diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
index ac009cb..75524ac 100644
--- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
+++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java
@@ -35,10 +35,12 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
+
import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.common.os.Platform;
+import com.jogamp.junit.util.JunitTracer;
import static org.junit.Assert.*;
import static java.lang.System.*;
@@ -52,7 +54,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class IntIntHashMapTest {
+public class IntIntHashMapTest extends JunitTracer {
private static int iterations;
private static IntIntUniqueRndValues pairs;
diff --git a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java
index 11bf765..3207683 100644
--- a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java
+++ b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java
@@ -35,10 +35,12 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
+
import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.common.os.Platform;
+import com.jogamp.junit.util.JunitTracer;
import static org.junit.Assert.*;
@@ -51,7 +53,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class IntObjectHashMapTest {
+public class IntObjectHashMapTest extends JunitTracer {
private static int iterations;
private static IntIntObjUniqueRndValues pairs;
diff --git a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
index f6ec4bc..90e54b9 100644
--- a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
+++ b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java
@@ -35,10 +35,12 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map.Entry;
+
import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.common.os.Platform;
+import com.jogamp.junit.util.JunitTracer;
import static org.junit.Assert.*;
import static java.lang.System.*;
@@ -52,7 +54,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LongIntHashMapTest {
+public class LongIntHashMapTest extends JunitTracer {
private static int iterations;
private static LongIntUniqueRndValues pairs;