commit b62632fcf187e7b4e7fb8150fb4d3290c1d0d16b
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Sat Dec 10 22:20:03 2016 +0000

    Some speedup in CubesGrid

diff --git a/src/main/java/org/distorted/library/DistortedCubesGrid.java b/src/main/java/org/distorted/library/DistortedCubesGrid.java
index 4eb02b8..2d5b949 100644
--- a/src/main/java/org/distorted/library/DistortedCubesGrid.java
+++ b/src/main/java/org/distorted/library/DistortedCubesGrid.java
@@ -66,6 +66,7 @@ class DistortedCubesGrid extends DistortedObjectGrid
    private int remainingVert;
    private int mSideBends;
    private int mEdgeNum;
+   private int mSideWalls;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // a Block is split into two triangles along the NE-SW line iff it is in the top-right
@@ -81,42 +82,36 @@ class DistortedCubesGrid extends DistortedObjectGrid
 
    private int computeDataLength(boolean frontOnly)
       {
-      int frontWalls=0, frontSegments=0, sideWalls=0, triangleShifts=0, windingShifts=0;
+      int frontWalls=0, frontSegments=0, triangleShifts=0, windingShifts=0;
       int shiftCol = (mCols-1)/2;
 
       boolean lastBlockIsNE=false;
       boolean thisBlockIsNE;        // the block we are currently looking at is split into
                                     // two triangles along the NE-SW line (rather than NW-SE)
       for(int row=0; row<mRows; row++)
-         {
-         if( mCols>=2 && (mCubes[row][shiftCol]%2 == 1) && (mCubes[row][shiftCol+1]%2 == 1) ) triangleShifts++;
+        {
+        if( mCols>=2 && (mCubes[row][shiftCol]%2 == 1) && (mCubes[row][shiftCol+1]%2 == 1) ) triangleShifts++;
 
-         for(int col=0; col<mCols; col++)
+        for(int col=0; col<mCols; col++)
+          {
+          if( mCubes[row][col]%2 == 1 )  // land
             {
-            if( mCubes[row][col]%2 == 1 )  // land
-              {
-              thisBlockIsNE = isNE(row,col);
-              if( thisBlockIsNE^lastBlockIsNE ) windingShifts++;
-              lastBlockIsNE = thisBlockIsNE;
-              frontWalls++;
-              if( col==mCols-1 || mCubes[row][col+1]%2 == 0 ) frontSegments++;
-              }
-              
-            if( (row==0 && mCubes[row][col]!=2) || (row!=0 && mCubes[row][col] != mCubes[row-1][col  ]) ) sideWalls++; // up
-            if( (col==0 && mCubes[row][col]!=2) || (col!=0 && mCubes[row][col] != mCubes[row  ][col-1]) ) sideWalls++; // left
-            if( row==mRows-1 && mCubes[row][col]!=2                                                     ) sideWalls++; // bottom
-            if( col==mCols-1 && mCubes[row][col]!=2                                                     ) sideWalls++; // right
+            thisBlockIsNE = isNE(row,col);
+            if( thisBlockIsNE^lastBlockIsNE ) windingShifts++;
+            lastBlockIsNE = thisBlockIsNE;
+            frontWalls++;
+            if( col==mCols-1 || mCubes[row][col+1]%2 == 0 ) frontSegments++;
             }
-         }
+          }
+        }
 
       int frontVert = 2*( frontWalls + 2*frontSegments - 1) +2*triangleShifts + windingShifts;
-      int sideVert  = 2*( sideWalls + mSideBends + mEdgeNum -1);
+      int sideVert  = 2*( mSideWalls + mSideBends + mEdgeNum -1);
       int firstWinding= (!frontOnly && (frontVert+1)%2==1 ) ? 1:0;
       int dataL = frontOnly ? frontVert : (frontVert+1) +firstWinding+ (1+sideVert+1) + (1+frontVert);
 /*
-      android.util.Log.e("CUBES","triangleShifts="+triangleShifts+" windingShifts="+windingShifts);
-      android.util.Log.e("CUBES","Winding1="+firstWinding+" frontVert="+frontVert+" sideVert="+sideVert);
-      android.util.Log.e("CUBES", "frontW="+frontWalls+" fSegments="+frontSegments+" sWalls="+sideWalls+" sSegments="+mEdgeNum+" sideBends="+mSideBends+" dataLen="+dataL );
+      android.util.Log.e("CUBES","triangleShifts="+triangleShifts+" windingShifts="+windingShifts+" winding1="+firstWinding+" frontVert="+frontVert+" sideVert="+sideVert);
+      android.util.Log.e("CUBES", "frontW="+frontWalls+" fSegments="+frontSegments+" sWalls="+mSideWalls+" sSegments="+mEdgeNum+" sideBends="+mSideBends+" dataLen="+dataL );
 */
       return dataL<0 ? 0:dataL;
       }
@@ -266,6 +261,8 @@ class DistortedCubesGrid extends DistortedObjectGrid
          {
          //android.util.Log.d("CUBES", "checking edge "+debug(e1));
 
+         mSideWalls++;
+
          if( e1.side==NORTH || e1.side==SOUTH )
            {
            for(j=i+1;j<mEdgeNum;j++)
