perf: use rustc-hash for HashMap and HashSet

This commit is contained in:
Cheong Lau 2025-10-22 02:33:30 +00:00 committed by GitHub
parent 4dae45733e
commit 5369b4eb29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 46 additions and 26 deletions

View file

@ -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<calloop::channel::Sender<TokenRequest>>,
failed_known_ssids: HashSet<String>,
failed_known_ssids: FxHashSet<String>,
hw_device_to_show: Option<HwAddress>,
}

View file

@ -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::<String, AccessPoint>::new();
let mut aps = FxHashMap::<String, AccessPoint>::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);