From 35e0629944a5a10a6f02b7960332a6a274b3ce0c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 15 Feb 2025 22:34:43 +0000 Subject: [PATCH] feat: simplify getrandom call (#325) New in getrandom 0.3, we can now get numbers directly. On some systems, this'll use special CPU instructions and can be instantaneous. We're not using them for crypto, so I'm not going to be picky. --- src/util.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util.rs b/src/util.rs index beb6b1ff6..5dc62a291 100644 --- a/src/util.rs +++ b/src/util.rs @@ -58,9 +58,8 @@ pub fn create_helper( any(windows, unix, target_os = "redox", target_os = "wasi") ))] if i == 3 { - let mut seed = [0u8; 8]; - if getrandom::fill(&mut seed).is_ok() { - rng.seed(u64::from_ne_bytes(seed)); + if let Ok(seed) = getrandom::u64() { + rng.seed(seed); } } let path = base.join(tmpname(&mut rng, prefix, suffix, random_len));