You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2012/02/02 17:11:16 UTC
svn commit: r1239694 -
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java
Author: erans
Date: Thu Feb 2 16:11:15 2012
New Revision: 1239694
URL: http://svn.apache.org/viewvc?rev=1239694&view=rev
Log:
MATH-734
Initialize "final" fields at point of declaration.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java?rev=1239694&r1=1239693&r2=1239694&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/ISAACRandom.java Thu Feb 2 16:11:15 2012
@@ -53,9 +53,9 @@ public class ISAACRandom extends BitsStr
/** The golden ratio */
private static final int GLD_RATIO = 0x9e3779b9;
/** The results given to the user */
- private int[] rsl;
+ private final int[] rsl = new int[SIZE];
/** The internal state */
- private int[] mem;
+ private final int[] mem = new int[SIZE];
/** Count through the results in rsl[] */
private int count;
/** Accumulator */
@@ -65,7 +65,7 @@ public class ISAACRandom extends BitsStr
/** Counter, guarantees cycle is at least 2^40 */
private int isaacC;
/** Service variable. */
- private transient int[] arr;
+ private final transient int[] arr = new int[8];
/** Service variable. */
private transient int isaacX;
/** Service variable. */
@@ -81,7 +81,6 @@ public class ISAACRandom extends BitsStr
* current time and system hash code of the instance as the seed.
*/
public ISAACRandom() {
- allocArrays();
setSeed(System.currentTimeMillis() + System.identityHashCode(this));
}
@@ -91,7 +90,6 @@ public class ISAACRandom extends BitsStr
* @param seed Initial seed.
*/
public ISAACRandom(long seed) {
- allocArrays();
setSeed(seed);
}
@@ -102,17 +100,9 @@ public class ISAACRandom extends BitsStr
* to the current time.
*/
public ISAACRandom(int[] seed) {
- allocArrays();
setSeed(seed);
}
- /** Allocate the pools arrays. */
- private void allocArrays() {
- rsl = new int[SIZE];
- mem = new int[SIZE];
- arr = new int[8];
- }
-
/** {@inheritDoc} */
@Override
public void setSeed(int seed) {