From 6de8ace67b26f039fb1c89a3fce4d5f2437c615c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 16 Aug 2014 11:31:04 +0200 Subject: IntIntHashMap: Reduce temp. ArrayList instances in clone --- src/java/com/jogamp/common/util/IntIntHashMap.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/java/com/jogamp/common/util') 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 entries = new ArrayList(); for(int i=table.length-1; i>=0; i--) { // single linked list -> ArrayList - final ArrayList entries = new ArrayList(); 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 { -- cgit v1.2.3