From e8c11aba87c4d80386ed234c7cac99d7cb78ce7d Mon Sep 17 00:00:00 2001 From: David Hoover Date: Thu, 10 May 2012 22:08:35 -0700 Subject: [PATCH] Nix unused locals in matrix operations. Compilers are presumably smart enough to throw away the bulk of that automagically, but some were storing the return value of a method call of some object that implemented an interface whic his a lot harder for it to realize won't have side effects. --- src/main/java/pythagoras/d/Matrix3.java | 30 ++++++++++++------------- src/main/java/pythagoras/d/Matrix4.java | 2 -- src/main/java/pythagoras/f/Matrix3.java | 30 ++++++++++++------------- src/main/java/pythagoras/f/Matrix4.java | 2 -- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/main/java/pythagoras/d/Matrix3.java b/src/main/java/pythagoras/d/Matrix3.java index ae6a86c..7007626 100644 --- a/src/main/java/pythagoras/d/Matrix3.java +++ b/src/main/java/pythagoras/d/Matrix3.java @@ -448,12 +448,12 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 multAffine (IMatrix3 other, Matrix3 result) { - double m00 = this.m00, m01 = this.m01, m02 = this.m02; - double m10 = this.m10, m11 = this.m11, m12 = this.m12; - double m20 = this.m20, m21 = this.m21, m22 = this.m22; - double om00 = other.m00(), om01 = other.m01(), om02 = other.m02(); - double om10 = other.m10(), om11 = other.m11(), om12 = other.m12(); - double om20 = other.m20(), om21 = other.m21(), om22 = other.m22(); + double m00 = this.m00, m01 = this.m01; + double m10 = this.m10, m11 = this.m11; + double m20 = this.m20, m21 = this.m21; + double om00 = other.m00(), om01 = other.m01(); + double om10 = other.m10(), om11 = other.m11(); + double om20 = other.m20(), om21 = other.m21(); return result.set(m00*om00 + m10*om01, m00*om10 + m10*om11, m00*om20 + m10*om21 + m20, @@ -512,9 +512,9 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 invertAffine (Matrix3 result) throws SingularMatrixException { - double m00 = this.m00, m01 = this.m01, m02 = this.m02; - double m10 = this.m10, m11 = this.m11, m12 = this.m12; - double m20 = this.m20, m21 = this.m21, m22 = this.m22; + double m00 = this.m00, m01 = this.m01; + double m10 = this.m10, m11 = this.m11; + double m20 = this.m20, m21 = this.m21; // compute the determinant, storing the subdeterminants for later use double det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { @@ -566,12 +566,12 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 lerpAffine (IMatrix3 other, double t, Matrix3 result) { - double m00 = this.m00, m01 = this.m01, m02 = this.m02; - double m10 = this.m10, m11 = this.m11, m12 = this.m12; - double m20 = this.m20, m21 = this.m21, m22 = this.m22; - double om00 = other.m00(), om01 = other.m01(), om02 = other.m02(); - double om10 = other.m10(), om11 = other.m11(), om12 = other.m12(); - double om20 = other.m20(), om21 = other.m21(), om22 = other.m22(); + double m00 = this.m00, m01 = this.m01; + double m10 = this.m10, m11 = this.m11; + double m20 = this.m20, m21 = this.m21; + double om00 = other.m00(), om01 = other.m01(); + double om10 = other.m10(), om11 = other.m11(); + double om20 = other.m20(), om21 = other.m21(); return result.set(m00 + t*(om00 - m00), m10 + t*(om10 - m10), m20 + t*(om20 - m20), diff --git a/src/main/java/pythagoras/d/Matrix4.java b/src/main/java/pythagoras/d/Matrix4.java index f3eebc6..abf8f1a 100644 --- a/src/main/java/pythagoras/d/Matrix4.java +++ b/src/main/java/pythagoras/d/Matrix4.java @@ -754,7 +754,6 @@ public final class Matrix4 implements IMatrix4, Serializable double m00 = this.m00, m10 = this.m10, m20 = this.m20, m30 = this.m30; double m01 = this.m01, m11 = this.m11, m21 = this.m21, m31 = this.m31; double m02 = this.m02, m12 = this.m12, m22 = this.m22, m32 = this.m32; - double m03 = this.m03, m13 = this.m13, m23 = this.m23, m33 = this.m33; // compute the determinant, storing the subdeterminants for later use double sd00 = m11*m22 - m21*m12; double sd10 = m01*m22 - m21*m02; @@ -826,7 +825,6 @@ public final class Matrix4 implements IMatrix4, Serializable double m00 = this.m00, m10 = this.m10, m20 = this.m20, m30 = this.m30; double m01 = this.m01, m11 = this.m11, m21 = this.m21, m31 = this.m31; double m02 = this.m02, m12 = this.m12, m22 = this.m22, m32 = this.m32; - double m03 = this.m03, m13 = this.m13, m23 = this.m23, m33 = this.m33; return result.set(m00 + t*(other.m00() - m00), m10 + t*(other.m10() - m10), m20 + t*(other.m20() - m20), diff --git a/src/main/java/pythagoras/f/Matrix3.java b/src/main/java/pythagoras/f/Matrix3.java index 408ed28..21824c6 100644 --- a/src/main/java/pythagoras/f/Matrix3.java +++ b/src/main/java/pythagoras/f/Matrix3.java @@ -448,12 +448,12 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 multAffine (IMatrix3 other, Matrix3 result) { - float m00 = this.m00, m01 = this.m01, m02 = this.m02; - float m10 = this.m10, m11 = this.m11, m12 = this.m12; - float m20 = this.m20, m21 = this.m21, m22 = this.m22; - float om00 = other.m00(), om01 = other.m01(), om02 = other.m02(); - float om10 = other.m10(), om11 = other.m11(), om12 = other.m12(); - float om20 = other.m20(), om21 = other.m21(), om22 = other.m22(); + float m00 = this.m00, m01 = this.m01; + float m10 = this.m10, m11 = this.m11; + float m20 = this.m20, m21 = this.m21; + float om00 = other.m00(), om01 = other.m01(); + float om10 = other.m10(), om11 = other.m11(); + float om20 = other.m20(), om21 = other.m21(); return result.set(m00*om00 + m10*om01, m00*om10 + m10*om11, m00*om20 + m10*om21 + m20, @@ -512,9 +512,9 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 invertAffine (Matrix3 result) throws SingularMatrixException { - float m00 = this.m00, m01 = this.m01, m02 = this.m02; - float m10 = this.m10, m11 = this.m11, m12 = this.m12; - float m20 = this.m20, m21 = this.m21, m22 = this.m22; + float m00 = this.m00, m01 = this.m01; + float m10 = this.m10, m11 = this.m11; + float m20 = this.m20, m21 = this.m21; // compute the determinant, storing the subdeterminants for later use float det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { @@ -566,12 +566,12 @@ public class Matrix3 implements IMatrix3, Serializable @Override // from IMatrix3 public Matrix3 lerpAffine (IMatrix3 other, float t, Matrix3 result) { - float m00 = this.m00, m01 = this.m01, m02 = this.m02; - float m10 = this.m10, m11 = this.m11, m12 = this.m12; - float m20 = this.m20, m21 = this.m21, m22 = this.m22; - float om00 = other.m00(), om01 = other.m01(), om02 = other.m02(); - float om10 = other.m10(), om11 = other.m11(), om12 = other.m12(); - float om20 = other.m20(), om21 = other.m21(), om22 = other.m22(); + float m00 = this.m00, m01 = this.m01; + float m10 = this.m10, m11 = this.m11; + float m20 = this.m20, m21 = this.m21; + float om00 = other.m00(), om01 = other.m01(); + float om10 = other.m10(), om11 = other.m11(); + float om20 = other.m20(), om21 = other.m21(); return result.set(m00 + t*(om00 - m00), m10 + t*(om10 - m10), m20 + t*(om20 - m20), diff --git a/src/main/java/pythagoras/f/Matrix4.java b/src/main/java/pythagoras/f/Matrix4.java index 4713697..bf15ac5 100644 --- a/src/main/java/pythagoras/f/Matrix4.java +++ b/src/main/java/pythagoras/f/Matrix4.java @@ -754,7 +754,6 @@ public final class Matrix4 implements IMatrix4, Serializable float m00 = this.m00, m10 = this.m10, m20 = this.m20, m30 = this.m30; float m01 = this.m01, m11 = this.m11, m21 = this.m21, m31 = this.m31; float m02 = this.m02, m12 = this.m12, m22 = this.m22, m32 = this.m32; - float m03 = this.m03, m13 = this.m13, m23 = this.m23, m33 = this.m33; // compute the determinant, storing the subdeterminants for later use float sd00 = m11*m22 - m21*m12; float sd10 = m01*m22 - m21*m02; @@ -826,7 +825,6 @@ public final class Matrix4 implements IMatrix4, Serializable float m00 = this.m00, m10 = this.m10, m20 = this.m20, m30 = this.m30; float m01 = this.m01, m11 = this.m11, m21 = this.m21, m31 = this.m31; float m02 = this.m02, m12 = this.m12, m22 = this.m22, m32 = this.m32; - float m03 = this.m03, m13 = this.m13, m23 = this.m23, m33 = this.m33; return result.set(m00 + t*(other.m00() - m00), m10 + t*(other.m10() - m10), m20 + t*(other.m20() - m20),