perf: use rustc-hash for HashMap and HashSet
This commit is contained in:
parent
4dae45733e
commit
5369b4eb29
17 changed files with 46 additions and 26 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -1129,6 +1129,7 @@ dependencies = [
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"memmap2 0.9.8",
|
"memmap2 0.9.8",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"switcheroo-control",
|
"switcheroo-control",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
@ -1201,6 +1202,7 @@ dependencies = [
|
||||||
"i18n-embed-fl",
|
"i18n-embed-fl",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|
@ -1222,6 +1224,7 @@ dependencies = [
|
||||||
"i18n-embed-fl",
|
"i18n-embed-fl",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|
@ -1276,6 +1279,7 @@ dependencies = [
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|
@ -1327,6 +1331,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -1348,6 +1353,7 @@ dependencies = [
|
||||||
"i18n-embed-fl",
|
"i18n-embed-fl",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|
@ -1540,6 +1546,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"libcosmic",
|
"libcosmic",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde",
|
"serde",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = fa
|
||||||
] }
|
] }
|
||||||
rust-embed = "8.7.2"
|
rust-embed = "8.7.2"
|
||||||
rust-embed-utils = "8.7.2"
|
rust-embed-utils = "8.7.2"
|
||||||
|
rustc-hash = "2.1"
|
||||||
rustix = { version = "1.1", features = ["fs", "process"] }
|
rustix = { version = "1.1", features = ["fs", "process"] }
|
||||||
zbus = { version = "5.11.0", default-features = false, features = ["tokio"] }
|
zbus = { version = "5.11.0", default-features = false, features = ["tokio"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ memmap2 = "0.9.8"
|
||||||
fastrand = "2.3.0"
|
fastrand = "2.3.0"
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
rustix.workspace = true
|
rustix.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" }
|
switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" }
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ use cosmic_app_list_config::{APP_ID, AppListConfig};
|
||||||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::State;
|
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::State;
|
||||||
use futures::future::pending;
|
use futures::future::pending;
|
||||||
use iced::{Alignment, Background, Length};
|
use iced::{Alignment, Background, Length};
|
||||||
use std::{borrow::Cow, collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
|
use rustc_hash::FxHashMap;
|
||||||
|
use std::{borrow::Cow, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
|
||||||
use switcheroo_control::Gpu;
|
use switcheroo_control::Gpu;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
@ -327,12 +328,12 @@ struct CosmicAppList {
|
||||||
wayland_sender: Option<Sender<WaylandRequest>>,
|
wayland_sender: Option<Sender<WaylandRequest>>,
|
||||||
seat: Option<WlSeat>,
|
seat: Option<WlSeat>,
|
||||||
rectangle_tracker: Option<RectangleTracker<DockItemId>>,
|
rectangle_tracker: Option<RectangleTracker<DockItemId>>,
|
||||||
rectangles: HashMap<DockItemId, iced::Rectangle>,
|
rectangles: FxHashMap<DockItemId, iced::Rectangle>,
|
||||||
dnd_offer: Option<DndOffer>,
|
dnd_offer: Option<DndOffer>,
|
||||||
is_listening_for_dnd: bool,
|
is_listening_for_dnd: bool,
|
||||||
gpus: Option<Vec<Gpu>>,
|
gpus: Option<Vec<Gpu>>,
|
||||||
active_workspaces: Vec<ExtWorkspaceHandleV1>,
|
active_workspaces: Vec<ExtWorkspaceHandleV1>,
|
||||||
output_list: HashMap<WlOutput, OutputInfo>,
|
output_list: FxHashMap<WlOutput, OutputInfo>,
|
||||||
locales: Vec<String>,
|
locales: Vec<String>,
|
||||||
overflow_favorites_popup: Option<window::Id>,
|
overflow_favorites_popup: Option<window::Id>,
|
||||||
overflow_active_popup: Option<window::Id>,
|
overflow_active_popup: Option<window::Id>,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ i18n-embed-fl.workspace = true
|
||||||
i18n-embed.workspace = true
|
i18n-embed.workspace = true
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ use cosmic_settings_subscriptions::{
|
||||||
};
|
};
|
||||||
use cosmic_time::{Instant, Timeline, anim, chain, id};
|
use cosmic_time::{Instant, Timeline, anim, chain, id};
|
||||||
|
|
||||||
use std::{collections::HashMap, path::PathBuf, sync::LazyLock, time::Duration};
|
use rustc_hash::FxHashMap;
|
||||||
|
use std::{path::PathBuf, sync::LazyLock, time::Duration};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
// XXX improve
|
// XXX improve
|
||||||
|
|
@ -80,7 +81,7 @@ struct CosmicBatteryApplet {
|
||||||
charging_limit: Option<bool>,
|
charging_limit: Option<bool>,
|
||||||
battery_percent: f64,
|
battery_percent: f64,
|
||||||
on_battery: bool,
|
on_battery: bool,
|
||||||
gpus: HashMap<PathBuf, GPUData>,
|
gpus: FxHashMap<PathBuf, GPUData>,
|
||||||
update_trigger: Option<UnboundedSender<()>>,
|
update_trigger: Option<UnboundedSender<()>>,
|
||||||
time_remaining: Duration,
|
time_remaining: Duration,
|
||||||
max_kbd_brightness: Option<i32>,
|
max_kbd_brightness: Option<i32>,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ i18n-embed.workspace = true
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
fastrand = "2.3.0"
|
fastrand = "2.3.0"
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
mem,
|
mem,
|
||||||
|
|
@ -357,7 +358,7 @@ pub struct BluerSessionState {
|
||||||
wake_up_discover_tx: Sender<()>,
|
wake_up_discover_tx: Sender<()>,
|
||||||
wake_up_discover_rx: Option<Receiver<()>>,
|
wake_up_discover_rx: Option<Receiver<()>>,
|
||||||
tx: Sender<BluerSessionEvent>,
|
tx: Sender<BluerSessionEvent>,
|
||||||
active_requests: Arc<Mutex<HashMap<BluerRequest, JoinHandle<anyhow::Result<()>>>>>,
|
active_requests: Arc<Mutex<FxHashMap<BluerRequest, JoinHandle<anyhow::Result<()>>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BluerSessionState {
|
impl BluerSessionState {
|
||||||
|
|
@ -540,7 +541,7 @@ impl BluerSessionState {
|
||||||
wake_up_discover_rx: Some(wake_up_discover_rx),
|
wake_up_discover_rx: Some(wake_up_discover_rx),
|
||||||
wake_up_discover_tx,
|
wake_up_discover_tx,
|
||||||
tx,
|
tx,
|
||||||
active_requests: Arc::new(Mutex::new(HashMap::new())),
|
active_requests: Default::default(),
|
||||||
};
|
};
|
||||||
self_.process_requests(req_rx);
|
self_.process_requests(req_rx);
|
||||||
self_.process_changes();
|
self_.process_changes();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ libcosmic = { workspace = true, features = [
|
||||||
"desktop",
|
"desktop",
|
||||||
] }
|
] }
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::HashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
|
@ -107,7 +107,7 @@ struct CosmicNetworkApplet {
|
||||||
timeline: Timeline,
|
timeline: Timeline,
|
||||||
toggle_wifi_ctr: u128,
|
toggle_wifi_ctr: u128,
|
||||||
token_tx: Option<calloop::channel::Sender<TokenRequest>>,
|
token_tx: Option<calloop::channel::Sender<TokenRequest>>,
|
||||||
failed_known_ssids: HashSet<String>,
|
failed_known_ssids: FxHashSet<String>,
|
||||||
hw_device_to_show: Option<HwAddress>,
|
hw_device_to_show: Option<HwAddress>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use cosmic_dbus_networkmanager::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use zbus::zvariant::ObjectPath;
|
use zbus::zvariant::ObjectPath;
|
||||||
|
|
||||||
|
|
@ -34,7 +35,7 @@ pub async fn handle_wireless_device(
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.map_or(DeviceState::Unknown, |s| s.into());
|
.map_or(DeviceState::Unknown, |s| s.into());
|
||||||
// Sort by strength and remove duplicates
|
// Sort by strength and remove duplicates
|
||||||
let mut aps = HashMap::<String, AccessPoint>::new();
|
let mut aps = FxHashMap::<String, AccessPoint>::default();
|
||||||
for ap in access_points {
|
for ap in access_points {
|
||||||
let ssid = String::from_utf8_lossy(ap.ssid().await?.as_slice()).into_owned();
|
let ssid = String::from_utf8_lossy(ap.ssid().await?.as_slice()).into_owned();
|
||||||
let wps_push = ap.flags().await?.contains(ApFlags::WPS_PBC);
|
let wps_push = ap.flags().await?.contains(ApFlags::WPS_PBC);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ license = "GPL-3.0-only"
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use cosmic::iced::{self, Subscription};
|
use cosmic::iced::{self, Subscription};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use std::collections::HashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use zbus::zvariant::{self, OwnedValue};
|
use zbus::zvariant::{self, OwnedValue};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -153,8 +153,11 @@ impl<'a> serde::Deserialize<'a> for Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl zvariant::Type for Layout {
|
impl zvariant::Type for Layout {
|
||||||
const SIGNATURE: &'static zvariant::Signature =
|
const SIGNATURE: &zvariant::Signature = <(
|
||||||
<(i32, HashMap<String, zvariant::Value>, Vec<zvariant::Value>)>::SIGNATURE;
|
i32,
|
||||||
|
FxHashMap<String, zvariant::Value>,
|
||||||
|
Vec<zvariant::Value>,
|
||||||
|
)>::SIGNATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, zvariant::DeserializeDict)]
|
#[derive(Clone, Debug, zvariant::DeserializeDict)]
|
||||||
|
|
@ -184,7 +187,7 @@ pub struct LayoutProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl zvariant::Type for LayoutProps {
|
impl zvariant::Type for LayoutProps {
|
||||||
const SIGNATURE: &'static zvariant::Signature = <HashMap<String, zvariant::Value>>::SIGNATURE;
|
const SIGNATURE: &zvariant::Signature = <FxHashMap<String, zvariant::Value>>::SIGNATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ cosmic-time.workspace = true
|
||||||
i18n-embed-fl.workspace = true
|
i18n-embed-fl.workspace = true
|
||||||
i18n-embed.workspace = true
|
i18n-embed.workspace = true
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,10 @@ use cctk::{
|
||||||
use cosmic::iced::futures;
|
use cosmic::iced::futures;
|
||||||
use cosmic_protocols::workspace::v2::client::zcosmic_workspace_handle_v2::TilingState;
|
use cosmic_protocols::workspace::v2::client::zcosmic_workspace_handle_v2::TilingState;
|
||||||
use futures::{SinkExt, channel::mpsc, executor::block_on};
|
use futures::{SinkExt, channel::mpsc, executor::block_on};
|
||||||
use std::{
|
use rustc_hash::FxHashSet;
|
||||||
collections::HashSet,
|
use std::os::{
|
||||||
os::{
|
fd::{FromRawFd, RawFd},
|
||||||
fd::{FromRawFd, RawFd},
|
unix::net::UnixStream,
|
||||||
unix::net::UnixStream,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
|
|
@ -79,7 +77,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender<TilingState>) -> SyncSender<AppRequest>
|
||||||
configured_output,
|
configured_output,
|
||||||
workspace_state: WorkspaceState::new(®istry_state, &qhandle),
|
workspace_state: WorkspaceState::new(®istry_state, &qhandle),
|
||||||
toplevel_info_state: ToplevelInfoState::new(®istry_state, &qhandle),
|
toplevel_info_state: ToplevelInfoState::new(®istry_state, &qhandle),
|
||||||
workspaces_with_previous_toplevel: HashSet::new(),
|
workspaces_with_previous_toplevel: FxHashSet::default(),
|
||||||
registry_state,
|
registry_state,
|
||||||
expected_output: None,
|
expected_output: None,
|
||||||
tx,
|
tx,
|
||||||
|
|
@ -167,7 +165,7 @@ pub struct State {
|
||||||
registry_state: RegistryState,
|
registry_state: RegistryState,
|
||||||
workspace_state: WorkspaceState,
|
workspace_state: WorkspaceState,
|
||||||
toplevel_info_state: ToplevelInfoState,
|
toplevel_info_state: ToplevelInfoState,
|
||||||
workspaces_with_previous_toplevel: HashSet<ext_workspace_handle_v1::ExtWorkspaceHandleV1>,
|
workspaces_with_previous_toplevel: FxHashSet<ext_workspace_handle_v1::ExtWorkspaceHandleV1>,
|
||||||
have_workspaces: bool,
|
have_workspaces: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ license = "GPL-3.0-only"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libcosmic.workspace = true
|
libcosmic.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
tracing-log.workspace = true
|
tracing-log.workspace = true
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::collections::HashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use cosmic_config::{CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry};
|
use cosmic_config::{CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
@ -8,13 +8,13 @@ use serde::{Deserialize, Serialize};
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CosmicPanelButtonConfig {
|
pub struct CosmicPanelButtonConfig {
|
||||||
/// configs indexed by panel name
|
/// configs indexed by panel name
|
||||||
pub configs: HashMap<String, IndividualConfig>,
|
pub configs: FxHashMap<String, IndividualConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CosmicPanelButtonConfig {
|
impl Default for CosmicPanelButtonConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
configs: HashMap::from([
|
configs: FxHashMap::from_iter([
|
||||||
(
|
(
|
||||||
"Panel".to_string(),
|
"Panel".to_string(),
|
||||||
IndividualConfig {
|
IndividualConfig {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue