]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #6073 : huonw/rust/core-rust-isaac, r=pcwalton
authorbors <bors@rust-lang.org>
Tue, 30 Apr 2013 01:24:37 +0000 (18:24 -0700)
committerbors <bors@rust-lang.org>
Tue, 30 Apr 2013 01:24:37 +0000 (18:24 -0700)
This replaces the wrapper around the runtime RNG with a pure Rust implementation of the same algorithm. This is much faster (up to 5x), and is hopefully safer.

There is still (a little) room for optimisation: testing by summing 100,000,000 random `u32`s indicates this is about ~~40-50%~~ 10% slower than the pure C implementation (running as standalone executable, not in the runtime).

(Only 6d50d55 is part of this PR, the first two are from #6058, but are required for the rt rng to be correct to compare against in the tests.)

1  2 
src/libcore/rand.rs

index 967a8cdf49bf3947037ad2d130471a2bfcb44a74,07e7defb1b5203c0fb2347921d285f6efe9e7a78..9fa099cabbfe9941d1e5579a08817272d1844aa2
@@@ -697,8 -844,9 +844,9 @@@ impl<R: Rng> Rng for @R 
   * Returns a random value of a Rand type, using the task's random number
   * generator.
   */
+ #[inline]
  pub fn random<T: Rand>() -> T {
 -    task_rng().gen()
 +    (*task_rng()).gen()
  }
  
  #[cfg(test)]