perf: replace rand with fastrand

This commit is contained in:
Cheong Lau 2025-10-03 23:25:51 +10:00 committed by GitHub
parent 98d6d33c87
commit d2e080427f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 12 deletions

View file

@ -12,7 +12,7 @@ futures.workspace = true
i18n-embed-fl.workspace = true
i18n-embed.workspace = true
libcosmic.workspace = true
rand = "0.9"
fastrand = "2.3.0"
rust-embed.workspace = true
tokio.workspace = true
tracing-log.workspace = true

View file

@ -24,7 +24,6 @@ use cosmic::{
};
use futures::{FutureExt, stream::FuturesUnordered};
use rand::Rng;
use tokio::{
spawn,
sync::{
@ -397,8 +396,7 @@ impl BluerSessionState {
),
))
.await;
let mut rng = rand::rng();
let pin_code = rng.random_range(0..999999);
let pin_code = fastrand::u32(0..999999);
Ok(format!("{:06}", pin_code))
})
})),
@ -437,8 +435,7 @@ impl BluerSessionState {
),
))
.await;
let mut rng = rand::rng();
let pin_code = rng.random_range(0..999999);
let pin_code = fastrand::u32(0..999999);
Ok(pin_code)
})
})),