diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-06 16:18:57 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-09 09:44:51 -0700 |
| commit | d9874bfb4079876dabc092c035d99b2d5b7f8a1c (patch) | |
| tree | 0d0ca368db8e61e6a9a688ba2fafe3a4fd5c8cfb /src | |
| parent | 33700532325627d8127d531dd83cca610681d48f (diff) | |
| download | rust-d9874bfb4079876dabc092c035d99b2d5b7f8a1c.tar.gz rust-d9874bfb4079876dabc092c035d99b2d5b7f8a1c.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librand/chacha.rs | 6 | ||||
| -rw-r--r-- | src/librand/isaac.rs | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/librand/chacha.rs b/src/librand/chacha.rs index df33e6e2ced..83d03bb265e 100644 --- a/src/librand/chacha.rs +++ b/src/librand/chacha.rs @@ -14,9 +14,9 @@ use core::prelude::*; use {Rng, SeedableRng, Rand}; -static KEY_WORDS : uint = 8; // 8 words for the 256-bit key -static STATE_WORDS : uint = 16; -static CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of this writing +const KEY_WORDS : uint = 8; // 8 words for the 256-bit key +const STATE_WORDS : uint = 16; +const CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of this writing /// A random number generator that uses the ChaCha20 algorithm [1]. /// diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 0a857da92bb..9bfd9177e34 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -16,9 +16,9 @@ use core::slice::raw; use {Rng, SeedableRng, Rand}; -static RAND_SIZE_LEN: u32 = 8; -static RAND_SIZE: u32 = 1 << (RAND_SIZE_LEN as uint); -static RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint); +const RAND_SIZE_LEN: u32 = 8; +const RAND_SIZE: u32 = 1 << (RAND_SIZE_LEN as uint); +const RAND_SIZE_UINT: uint = 1 << (RAND_SIZE_LEN as uint); /// A random number generator that uses the ISAAC algorithm[1]. /// @@ -251,8 +251,8 @@ impl Rand for IsaacRng { } } -static RAND_SIZE_64_LEN: uint = 8; -static RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN; +const RAND_SIZE_64_LEN: uint = 8; +const RAND_SIZE_64: uint = 1 << RAND_SIZE_64_LEN; /// A random number generator that uses ISAAC-64[1], the 64-bit /// variant of the ISAAC algorithm. @@ -356,8 +356,8 @@ impl Isaac64Rng { // abbreviations let mut a = self.a; let mut b = self.b + self.c; - static MIDPOINT: uint = RAND_SIZE_64 / 2; - static MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; + const MIDPOINT: uint = RAND_SIZE_64 / 2; + const MP_VEC: [(uint, uint), .. 2] = [(0,MIDPOINT), (MIDPOINT, 0)]; macro_rules! ind ( ($x:expr) => { *self.mem.unsafe_get(($x as uint >> 3) & (RAND_SIZE_64 - 1)) |
