diff --git a/Cargo.lock b/Cargo.lock index ba6fbe23..21cceb3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1129,6 +1129,7 @@ dependencies = [ "libcosmic", "memmap2 0.9.8", "rust-embed", + "rustc-hash 2.1.1", "rustix 1.1.2", "switcheroo-control", "tokio", @@ -1201,6 +1202,7 @@ dependencies = [ "i18n-embed-fl", "libcosmic", "rust-embed", + "rustc-hash 2.1.1", "tokio", "tracing", "tracing-log", @@ -1222,6 +1224,7 @@ dependencies = [ "i18n-embed-fl", "libcosmic", "rust-embed", + "rustc-hash 2.1.1", "tokio", "tracing", "tracing-log", @@ -1276,6 +1279,7 @@ dependencies = [ "itertools 0.14.0", "libcosmic", "rust-embed", + "rustc-hash 2.1.1", "tokio", "tracing", "tracing-log", @@ -1327,6 +1331,7 @@ version = "0.1.0" dependencies = [ "futures", "libcosmic", + "rustc-hash 2.1.1", "serde", "tokio", "tracing", @@ -1348,6 +1353,7 @@ dependencies = [ "i18n-embed-fl", "libcosmic", "rust-embed", + "rustc-hash 2.1.1", "tokio", "tracing", "tracing-log", @@ -1540,6 +1546,7 @@ version = "0.1.0" dependencies = [ "cosmic-config", "libcosmic", + "rustc-hash 2.1.1", "serde", "tracing", "tracing-log", diff --git a/Cargo.toml b/Cargo.toml index 0fb226fb..a8c35094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = fa ] } rust-embed = "8.7.2" rust-embed-utils = "8.7.2" +rustc-hash = "2.1" rustix = { version = "1.1", features = ["fs", "process"] } zbus = { version = "5.11.0", default-features = false, features = ["tokio"] } tracing = "0.1" diff --git a/cosmic-app-list/Cargo.toml b/cosmic-app-list/Cargo.toml index ead0dff4..17474d99 100644 --- a/cosmic-app-list/Cargo.toml +++ b/cosmic-app-list/Cargo.toml @@ -19,6 +19,7 @@ memmap2 = "0.9.8" fastrand = "2.3.0" rust-embed.workspace = true rustix.workspace = true +rustc-hash.workspace = true switcheroo-control = { git = "https://github.com/pop-os/dbus-settings-bindings" } tokio.workspace = true tracing-log.workspace = true diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index e93e7a86..266e10be 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -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 futures::future::pending; 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 tokio::time::sleep; use url::Url; @@ -327,12 +328,12 @@ struct CosmicAppList { wayland_sender: Option>, seat: Option, rectangle_tracker: Option>, - rectangles: HashMap, + rectangles: FxHashMap, dnd_offer: Option, is_listening_for_dnd: bool, gpus: Option>, active_workspaces: Vec, - output_list: HashMap, + output_list: FxHashMap, locales: Vec, overflow_favorites_popup: Option, overflow_active_popup: Option, diff --git a/cosmic-applet-battery/Cargo.toml b/cosmic-applet-battery/Cargo.toml index 368c8fda..7692e53a 100644 --- a/cosmic-applet-battery/Cargo.toml +++ b/cosmic-applet-battery/Cargo.toml @@ -17,6 +17,7 @@ i18n-embed-fl.workspace = true i18n-embed.workspace = true libcosmic.workspace = true rust-embed.workspace = true +rustc-hash.workspace = true tokio.workspace = true tracing-log.workspace = true tracing-subscriber.workspace = true diff --git a/cosmic-applet-battery/src/app.rs b/cosmic-applet-battery/src/app.rs index 30bbabfe..26fe9c0d 100644 --- a/cosmic-applet-battery/src/app.rs +++ b/cosmic-applet-battery/src/app.rs @@ -40,7 +40,8 @@ use cosmic_settings_subscriptions::{ }; 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; // XXX improve @@ -80,7 +81,7 @@ struct CosmicBatteryApplet { charging_limit: Option, battery_percent: f64, on_battery: bool, - gpus: HashMap, + gpus: FxHashMap, update_trigger: Option>, time_remaining: Duration, max_kbd_brightness: Option, diff --git a/cosmic-applet-bluetooth/Cargo.toml b/cosmic-applet-bluetooth/Cargo.toml index a7d888f8..a4e0e184 100644 --- a/cosmic-applet-bluetooth/Cargo.toml +++ b/cosmic-applet-bluetooth/Cargo.toml @@ -14,6 +14,7 @@ i18n-embed.workspace = true libcosmic.workspace = true fastrand = "2.3.0" rust-embed.workspace = true +rustc-hash.workspace = true tokio.workspace = true tracing-log.workspace = true tracing-subscriber.workspace = true diff --git a/cosmic-applet-bluetooth/src/bluetooth.rs b/cosmic-applet-bluetooth/src/bluetooth.rs index 35e7886e..46903d0e 100644 --- a/cosmic-applet-bluetooth/src/bluetooth.rs +++ b/cosmic-applet-bluetooth/src/bluetooth.rs @@ -1,8 +1,9 @@ // Copyright 2023 System76 // SPDX-License-Identifier: GPL-3.0-only +use rustc_hash::FxHashMap; + use std::{ - collections::{HashMap, HashSet}, fmt::Debug, hash::Hash, mem, @@ -357,7 +358,7 @@ pub struct BluerSessionState { wake_up_discover_tx: Sender<()>, wake_up_discover_rx: Option>, tx: Sender, - active_requests: Arc>>>>, + active_requests: Arc>>>>, } impl BluerSessionState { @@ -540,7 +541,7 @@ impl BluerSessionState { wake_up_discover_rx: Some(wake_up_discover_rx), wake_up_discover_tx, tx, - active_requests: Arc::new(Mutex::new(HashMap::new())), + active_requests: Default::default(), }; self_.process_requests(req_rx); self_.process_changes(); diff --git a/cosmic-applet-network/Cargo.toml b/cosmic-applet-network/Cargo.toml index aa85a8a3..f05b676e 100644 --- a/cosmic-applet-network/Cargo.toml +++ b/cosmic-applet-network/Cargo.toml @@ -21,6 +21,7 @@ libcosmic = { workspace = true, features = [ "desktop", ] } rust-embed.workspace = true +rustc-hash.workspace = true tokio.workspace = true tracing-log.workspace = true tracing-subscriber.workspace = true diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index a89932fd..891e0a21 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -1,4 +1,4 @@ -use std::collections::HashSet; +use rustc_hash::FxHashSet; use std::sync::LazyLock; use cosmic::{ @@ -107,7 +107,7 @@ struct CosmicNetworkApplet { timeline: Timeline, toggle_wifi_ctr: u128, token_tx: Option>, - failed_known_ssids: HashSet, + failed_known_ssids: FxHashSet, hw_device_to_show: Option, } diff --git a/cosmic-applet-network/src/network_manager/available_wifi.rs b/cosmic-applet-network/src/network_manager/available_wifi.rs index c6be8762..3fd7fae1 100644 --- a/cosmic-applet-network/src/network_manager/available_wifi.rs +++ b/cosmic-applet-network/src/network_manager/available_wifi.rs @@ -9,6 +9,7 @@ use cosmic_dbus_networkmanager::{ }; use futures_util::StreamExt; +use rustc_hash::FxHashMap; use std::collections::HashMap; use zbus::zvariant::ObjectPath; @@ -34,7 +35,7 @@ pub async fn handle_wireless_device( .unwrap_or_default() .map_or(DeviceState::Unknown, |s| s.into()); // Sort by strength and remove duplicates - let mut aps = HashMap::::new(); + let mut aps = FxHashMap::::default(); for ap in access_points { let ssid = String::from_utf8_lossy(ap.ssid().await?.as_slice()).into_owned(); let wps_push = ap.flags().await?.contains(ApFlags::WPS_PBC); diff --git a/cosmic-applet-status-area/Cargo.toml b/cosmic-applet-status-area/Cargo.toml index a188b7b6..6880270b 100644 --- a/cosmic-applet-status-area/Cargo.toml +++ b/cosmic-applet-status-area/Cargo.toml @@ -8,6 +8,7 @@ license = "GPL-3.0-only" futures.workspace = true libcosmic.workspace = true serde.workspace = true +rustc-hash.workspace = true tokio.workspace = true tracing.workspace = true tracing-log.workspace = true diff --git a/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs b/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs index b786e8a2..c9e17218 100644 --- a/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs +++ b/cosmic-applet-status-area/src/subscriptions/status_notifier_item.rs @@ -3,7 +3,7 @@ use cosmic::iced::{self, Subscription}; use futures::{FutureExt, StreamExt}; -use std::collections::HashMap; +use rustc_hash::FxHashMap; use zbus::zvariant::{self, OwnedValue}; #[derive(Clone, Debug)] @@ -153,8 +153,11 @@ impl<'a> serde::Deserialize<'a> for Layout { } impl zvariant::Type for Layout { - const SIGNATURE: &'static zvariant::Signature = - <(i32, HashMap, Vec)>::SIGNATURE; + const SIGNATURE: &zvariant::Signature = <( + i32, + FxHashMap, + Vec, + )>::SIGNATURE; } #[derive(Clone, Debug, zvariant::DeserializeDict)] @@ -184,7 +187,7 @@ pub struct LayoutProps { } impl zvariant::Type for LayoutProps { - const SIGNATURE: &'static zvariant::Signature = >::SIGNATURE; + const SIGNATURE: &zvariant::Signature = >::SIGNATURE; } #[allow(dead_code)] diff --git a/cosmic-applet-tiling/Cargo.toml b/cosmic-applet-tiling/Cargo.toml index 456adf09..feffc317 100644 --- a/cosmic-applet-tiling/Cargo.toml +++ b/cosmic-applet-tiling/Cargo.toml @@ -14,6 +14,7 @@ cosmic-time.workspace = true i18n-embed-fl.workspace = true i18n-embed.workspace = true rust-embed.workspace = true +rustc-hash.workspace = true tokio.workspace = true tracing-log.workspace = true tracing-subscriber.workspace = true diff --git a/cosmic-applet-tiling/src/wayland.rs b/cosmic-applet-tiling/src/wayland.rs index 3fe6ac03..5d028276 100644 --- a/cosmic-applet-tiling/src/wayland.rs +++ b/cosmic-applet-tiling/src/wayland.rs @@ -20,12 +20,10 @@ use cctk::{ use cosmic::iced::futures; use cosmic_protocols::workspace::v2::client::zcosmic_workspace_handle_v2::TilingState; use futures::{SinkExt, channel::mpsc, executor::block_on}; -use std::{ - collections::HashSet, - os::{ - fd::{FromRawFd, RawFd}, - unix::net::UnixStream, - }, +use rustc_hash::FxHashSet; +use std::os::{ + fd::{FromRawFd, RawFd}, + unix::net::UnixStream, }; use tracing::error; use wayland_client::{ @@ -79,7 +77,7 @@ pub fn spawn_workspaces(tx: mpsc::Sender) -> SyncSender configured_output, workspace_state: WorkspaceState::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, expected_output: None, tx, @@ -167,7 +165,7 @@ pub struct State { registry_state: RegistryState, workspace_state: WorkspaceState, toplevel_info_state: ToplevelInfoState, - workspaces_with_previous_toplevel: HashSet, + workspaces_with_previous_toplevel: FxHashSet, have_workspaces: bool, } diff --git a/cosmic-panel-button/Cargo.toml b/cosmic-panel-button/Cargo.toml index 2138aadf..613e6ba0 100644 --- a/cosmic-panel-button/Cargo.toml +++ b/cosmic-panel-button/Cargo.toml @@ -6,6 +6,7 @@ license = "GPL-3.0-only" [dependencies] libcosmic.workspace = true +rustc-hash.workspace = true tracing.workspace = true tracing-subscriber.workspace = true tracing-log.workspace = true diff --git a/cosmic-panel-button/src/config.rs b/cosmic-panel-button/src/config.rs index ac6bc571..591fbf30 100644 --- a/cosmic-panel-button/src/config.rs +++ b/cosmic-panel-button/src/config.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use rustc_hash::FxHashMap; use cosmic_config::{CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry}; use serde::{Deserialize, Serialize}; @@ -8,13 +8,13 @@ use serde::{Deserialize, Serialize}; #[serde(deny_unknown_fields)] pub struct CosmicPanelButtonConfig { /// configs indexed by panel name - pub configs: HashMap, + pub configs: FxHashMap, } impl Default for CosmicPanelButtonConfig { fn default() -> Self { Self { - configs: HashMap::from([ + configs: FxHashMap::from_iter([ ( "Panel".to_string(), IndividualConfig {