diff options
author | 2024-04-01 11:59:46 +0200 | |
---|---|---|
committer | 2024-04-01 12:00:15 +0200 | |
commit | f5bcfec8211c04c4b05f63d01d52d3e5d2cc123e (patch) | |
tree | 4a9f0699548cea15b43743dcf00d5628890610ab /futures | |
parent | 14ed71e09b648693dfca9eb29f14147c5c03a6bc (diff) | |
download | iced-f5bcfec8211c04c4b05f63d01d52d3e5d2cc123e.tar.gz iced-f5bcfec8211c04c4b05f63d01d52d3e5d2cc123e.tar.bz2 iced-f5bcfec8211c04c4b05f63d01d52d3e5d2cc123e.zip |
Use `rustc-hash` for most of our `HashMap` and `HashSet` instances
Diffstat (limited to 'futures')
-rw-r--r-- | futures/Cargo.toml | 1 | ||||
-rw-r--r-- | futures/src/backend/native/async_std.rs | 3 | ||||
-rw-r--r-- | futures/src/backend/native/smol.rs | 3 | ||||
-rw-r--r-- | futures/src/backend/native/tokio.rs | 3 | ||||
-rw-r--r-- | futures/src/subscription.rs | 4 | ||||
-rw-r--r-- | futures/src/subscription/tracker.rs | 9 |
6 files changed, 11 insertions, 12 deletions
diff --git a/futures/Cargo.toml b/futures/Cargo.toml index 69a915e4..bbcfe01c 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -22,6 +22,7 @@ iced_core.workspace = true futures.workspace = true log.workspace = true +rustc-hash.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] async-std.workspace = true diff --git a/futures/src/backend/native/async_std.rs b/futures/src/backend/native/async_std.rs index 52b0e914..b7da5e90 100644 --- a/futures/src/backend/native/async_std.rs +++ b/futures/src/backend/native/async_std.rs @@ -18,8 +18,7 @@ impl crate::Executor for Executor { pub mod time { //! Listen and react to time. - use crate::core::Hasher; - use crate::subscription::{self, Subscription}; + use crate::subscription::{self, Hasher, Subscription}; /// Returns a [`Subscription`] that produces messages at a set interval. /// diff --git a/futures/src/backend/native/smol.rs b/futures/src/backend/native/smol.rs index 00d13d35..aaf1518c 100644 --- a/futures/src/backend/native/smol.rs +++ b/futures/src/backend/native/smol.rs @@ -17,8 +17,7 @@ impl crate::Executor for Executor { pub mod time { //! Listen and react to time. - use crate::core::Hasher; - use crate::subscription::{self, Subscription}; + use crate::subscription::{self, Hasher, Subscription}; /// Returns a [`Subscription`] that produces messages at a set interval. /// diff --git a/futures/src/backend/native/tokio.rs b/futures/src/backend/native/tokio.rs index 4698a105..3ab7f675 100644 --- a/futures/src/backend/native/tokio.rs +++ b/futures/src/backend/native/tokio.rs @@ -22,8 +22,7 @@ impl crate::Executor for Executor { pub mod time { //! Listen and react to time. - use crate::core::Hasher; - use crate::subscription::{self, Subscription}; + use crate::subscription::{self, Hasher, Subscription}; /// Returns a [`Subscription`] that produces messages at a set interval. /// diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs index 7537c022..93e35608 100644 --- a/futures/src/subscription.rs +++ b/futures/src/subscription.rs @@ -4,7 +4,6 @@ mod tracker; pub use tracker::Tracker; use crate::core::event::{self, Event}; -use crate::core::Hasher; use crate::futures::{Future, Stream}; use crate::{BoxStream, MaybeSend}; @@ -18,6 +17,9 @@ use std::hash::Hash; /// It is the input of a [`Subscription`]. pub type EventStream = BoxStream<(Event, event::Status)>; +/// The hasher used for identifying subscriptions. +pub type Hasher = rustc_hash::FxHasher; + /// A request to listen to external events. /// /// Besides performing async actions on demand with `Command`, most diff --git a/futures/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs index 15ed5b87..277a446b 100644 --- a/futures/src/subscription/tracker.rs +++ b/futures/src/subscription/tracker.rs @@ -1,12 +1,11 @@ use crate::core::event::{self, Event}; -use crate::core::Hasher; -use crate::subscription::Recipe; +use crate::subscription::{Hasher, Recipe}; use crate::{BoxFuture, MaybeSend}; use futures::channel::mpsc; use futures::sink::{Sink, SinkExt}; +use rustc_hash::FxHashMap; -use std::collections::HashMap; use std::hash::Hasher as _; /// A registry of subscription streams. @@ -18,7 +17,7 @@ use std::hash::Hasher as _; /// [`Subscription`]: crate::Subscription #[derive(Debug, Default)] pub struct Tracker { - subscriptions: HashMap<u64, Execution>, + subscriptions: FxHashMap<u64, Execution>, } #[derive(Debug)] @@ -31,7 +30,7 @@ impl Tracker { /// Creates a new empty [`Tracker`]. pub fn new() -> Self { Self { - subscriptions: HashMap::new(), + subscriptions: FxHashMap::default(), } } |