arnaucube
arnaucube/poulpyPublic Self-hosted repository
remove `OsRng` from `sample/src/source.rs`
Janmajaya Mall janmajayamall@protonmail.com
Fri, 04 Jul 2025 17:56:30 +0530
commit

2a5e0e7dc30f3b62b02371c68e7b9f52ba93d0ed

parent

30b5edc5360fe15a7be233726a5f6b328c26a637

1 files changed, 4 insertions(+), 13 deletions(-)

jump to
M sampling/src/source.rs → sampling/src/source.rs

@@ -1,6 +1,6 @@

use rand_chacha::ChaCha8Rng; use rand_chacha::rand_core::SeedableRng; -use rand_core::{OsRng, RngCore, TryRngCore}; +use rand_core::RngCore; const MAXF64: f64 = 9007199254740992.0;

@@ -8,12 +8,6 @@ pub struct Source {

source: ChaCha8Rng, } -pub fn new_seed() -> [u8; 32] { - let mut seed = [0u8; 32]; - OsRng.try_fill_bytes(&mut seed).unwrap(); - seed -} - impl Source { pub fn new(seed: [u8; 32]) -> Source { Source {

@@ -21,14 +15,11 @@ source: ChaCha8Rng::from_seed(seed),

} } - pub fn new_seed(&mut self) -> [u8; 32] { - let mut seed: [u8; 32] = [0u8; 32]; + pub fn branch(&mut self) -> Self { + let mut seed = [0; 32]; self.source.fill_bytes(&mut seed); - seed - } - pub fn branch(&mut self) -> Self { - Source::new(self.new_seed()) + Source::new(seed) } #[inline(always)]