Skip to content

Commit d2e0804

Browse files
authored
perf: replace rand with fastrand
1 parent 98d6d33 commit d2e0804

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmic-app-list/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ image = { version = "0.25.8", default-features = false }
1616
itertools = "0.14.0"
1717
libcosmic.workspace = true
1818
memmap2 = "0.9.8"
19-
rand = "0.9.2"
19+
fastrand = "2.3.0"
2020
rust-embed.workspace = true
2121
rustix.workspace = true
2222
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" }

cosmic-app-list/src/app.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::Sta
5454
use futures::future::pending;
5555
use iced::{Alignment, Background, Length};
5656
use itertools::Itertools;
57-
use rand::{Rng, rng};
5857
use std::{borrow::Cow, collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
5958
use switcheroo_control::Gpu;
6059
use tokio::time::sleep;
@@ -1084,8 +1083,7 @@ impl cosmic::Application for CosmicAppList {
10841083
}
10851084
self.active_list.clear();
10861085
let subscription_ctr = self.subscription_ctr;
1087-
let mut rng = rng();
1088-
let rand_d = rng.random_range(0..100);
1086+
let rand_d = fastrand::u64(0..100);
10891087
return iced::Task::perform(
10901088
async move {
10911089
if let Some(millis) = 2u64

cosmic-applet-bluetooth/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ futures.workspace = true
1212
i18n-embed-fl.workspace = true
1313
i18n-embed.workspace = true
1414
libcosmic.workspace = true
15-
rand = "0.9"
15+
fastrand = "2.3.0"
1616
rust-embed.workspace = true
1717
tokio.workspace = true
1818
tracing-log.workspace = true

cosmic-applet-bluetooth/src/bluetooth.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use cosmic::{
2424
};
2525

2626
use futures::{FutureExt, stream::FuturesUnordered};
27-
use rand::Rng;
2827
use tokio::{
2928
spawn,
3029
sync::{
@@ -397,8 +396,7 @@ impl BluerSessionState {
397396
),
398397
))
399398
.await;
400-
let mut rng = rand::rng();
401-
let pin_code = rng.random_range(0..999999);
399+
let pin_code = fastrand::u32(0..999999);
402400
Ok(format!("{:06}", pin_code))
403401
})
404402
})),
@@ -437,8 +435,7 @@ impl BluerSessionState {
437435
),
438436
))
439437
.await;
440-
let mut rng = rand::rng();
441-
let pin_code = rng.random_range(0..999999);
438+
let pin_code = fastrand::u32(0..999999);
442439
Ok(pin_code)
443440
})
444441
})),

0 commit comments

Comments
 (0)