Skip to content

Commit 35e0629

Browse files
authored
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.
1 parent 1e5059f commit 35e0629

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/util.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ pub fn create_helper<R>(
5858
any(windows, unix, target_os = "redox", target_os = "wasi")
5959
))]
6060
if i == 3 {
61-
let mut seed = [0u8; 8];
62-
if getrandom::fill(&mut seed).is_ok() {
63-
rng.seed(u64::from_ne_bytes(seed));
61+
if let Ok(seed) = getrandom::u64() {
62+
rng.seed(seed);
6463
}
6564
}
6665
let path = base.join(tmpname(&mut rng, prefix, suffix, random_len));

0 commit comments

Comments
 (0)