Skip to content

Commit 0c0a925

Browse files
committed
rand: Convert statics to constants
This leaves the ziggurat tables as `pub static` as they're likely too large to want to go into the metadata anyway.
1 parent 3e14f7a commit 0c0a925

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

chacha.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use core::prelude::*;
1414

1515
use {Rng, SeedableRng, Rand};
1616

17-
static KEY_WORDS : uint = 8; // 8 words for the 256-bit key
18-
static STATE_WORDS : uint = 16;
19-
static CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of this writing
17+
const KEY_WORDS : uint = 8; // 8 words for the 256-bit key
18+
const STATE_WORDS : uint = 16;
19+
const CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of this writing
2020

2121
/// A random number generator that uses the ChaCha20 algorithm [1].
2222
///

isaac.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use core::slice::raw;
1616

1717
use {Rng, SeedableRng, Rand};
1818

19-
static RAND_SIZE_LEN: u32 = 8;
20-
static RAND_SIZE: u32 = 1 << (RAND_SIZE_LEN as uint);
21-
static RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint);
19+
const RAND_SIZE_LEN: u32 = 8;
20+
const RAND_SIZE: u32 = 1 << (RAND_SIZE_LEN as uint);
21+
const RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint);
2222

2323
/// A random number generator that uses the ISAAC algorithm[1].
2424
///
@@ -251,8 +251,8 @@ impl Rand for IsaacRng {
251251
}
252252
}
253253

254-
static RAND_SIZE_64_LEN: uint = 8;
255-
static RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN;
254+
const RAND_SIZE_64_LEN: uint = 8;
255+
const RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN;
256256

257257
/// A random number generator that uses ISAAC-64[1], the 64-bit
258258
/// variant of the ISAAC algorithm.
@@ -356,8 +356,8 @@ impl Isaac64Rng {
356356
// abbreviations
357357
let mut a = self.a;
358358
let mut b = self.b + self.c;
359-
static MIDPOINT: uint = RAND_SIZE_64 / 2;
360-
static MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
359+
const MIDPOINT: uint = RAND_SIZE_64 / 2;
360+
const MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)];
361361
macro_rules! ind (
362362
($x:expr) => {
363363
*self.mem.unsafe_get(($x as uint >> 3) & (RAND_SIZE_64 - 1))

0 commit comments

Comments
 (0)