changeset 3609:a16837d73130

FixA: Using trove to map int->int instead of bloated generics. flys-artifacts/trunk@5238 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 22 Aug 2012 14:51:19 +0000
parents 53aa395a29e0
children 66f539df4e8b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java
diffstat 2 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Aug 22 13:47:26 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Aug 22 14:51:19 2012 +0000
@@ -1,3 +1,8 @@
+2012-08-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java:
+	  Using trove to map int->int instead of bloated generics.
+
 2012-08-22	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Aug 22 13:47:26 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Aug 22 14:51:19 2012 +0000
@@ -24,9 +24,10 @@
 import de.intevation.flys.utils.DateAverager;
 import de.intevation.flys.utils.KMIndex;
 
+import gnu.trove.TIntIntHashMap;
+
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 
 import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
@@ -129,11 +130,11 @@
 
         IdsFilter idsFilter = new IdsFilter(events);
 
-        ArrayList<HashMap<Integer, Integer>> col2indices =
-            new ArrayList<HashMap<Integer, Integer>>(analysisPeriods.length);
+        TIntIntHashMap [] col2indices =
+            new TIntIntHashMap[analysisPeriods.length];
 
         for (int i = 0; i < analysisPeriods.length; ++i) {
-            col2indices.add(new HashMap<Integer, Integer>());
+            col2indices[i] = new TIntIntHashMap();
         }
 
         for (int row = 0, R = parameters.size(); row < R; ++row) {
@@ -151,7 +152,7 @@
 
             for (int ap = 0; ap < analysisPeriods.length; ++ap) {
                 DateRange analysisPeriod = analysisPeriods[ap];
-                HashMap<Integer, Integer> col2index = col2indices.get(ap);
+                TIntIntHashMap col2index = col2indices[ap];
 
                 DateRangeFilter drf = new DateRangeFilter(
                     analysisPeriod.getFrom(),
@@ -210,18 +211,11 @@
                         Date date = column.getDate();
                         String description = column.getDescription();
 
-                        Integer colIdx = column.getIndex();
-                        Integer index = col2index.get(colIdx);
-                        if (index == null) {
-                            index = col2index.size();
-                            col2index.put(colIdx, index);
-                        }
-
                         QWD qwd = new QWD(
                             wq[1], wq[0],
                             description,
                             date, true,
-                            dw, index);
+                            dw, getIndex(col2index, column.getIndex()));
 
                         qwds.add(qwd);
 
@@ -286,5 +280,14 @@
 
         return results;
     }
+
+    private static final int getIndex(TIntIntHashMap map, int colIdx) {
+        if (map.containsKey(colIdx)) {
+            return map.get(colIdx);
+        }
+        int index = map.size();
+        map.put(colIdx, index);
+        return index;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org