changeset 662:60f24fca574a

BackJumpCorrector: Simpified array swapping. flys-artifacts/trunk@2072 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 07 Jun 2011 21:01:09 +0000
parents fdc898a134a7
children 51172d56e8bc
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Jun 07 15:05:12 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Jun 07 21:01:09 2011 +0000
@@ -1,3 +1,8 @@
+2011-06-07  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java:
+	  Simpified array swapping.
+
 2011-06-07  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java	Tue Jun 07 15:05:12 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java	Tue Jun 07 21:01:09 2011 +0000
@@ -264,27 +264,19 @@
         return array;
     }
 
-    public static final double [] swapClone(double [] array) {
-        double [] out = new double[array.length];
-        int lo = 0;
+    public static final double [] swapClone(double [] in) {
+        double [] out = new double[in.length];
 
-        int hi = array.length-1;
-        while (hi > lo) {
-            out[lo] = array[hi];
-            out[hi] = array[lo];
-            ++lo;
-            --hi;
+        for (int j = out.length-1, i = 0; j >= 0;) {
+            out[j--] = in[i++];
         }
+
         return out;
     }
 
     public static final double [] sumDiffs(double [] in) {
         double [] out = new double[in.length];
 
-        if (out.length > 0) {
-            out[0] = 0d;
-        }
-
         for (int i = 1; i < out.length; ++i) {
             out[i] = out[i-1] + Math.abs(in[i-1] - in[i]);
         }

http://dive4elements.wald.intevation.org