From cca11ea9cc4baaa71474700fe3bcbe540ff89bc8 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 9 Oct 2021 15:22:36 +0200 Subject: [PATCH] Optimization: less HashMap, more AHashMap --- egui/src/any/any_map.rs | 6 +++--- egui/src/any/serializable/any_map.rs | 6 +++--- egui/src/any/serializable/type_map.rs | 4 ++-- egui/src/any/type_map.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/egui/src/any/any_map.rs b/egui/src/any/any_map.rs index ca785397..5a1909e9 100644 --- a/egui/src/any/any_map.rs +++ b/egui/src/any/any_map.rs @@ -1,15 +1,15 @@ use crate::any::element::{AnyMapElement, AnyMapTrait}; +use crate::epaint::ahash::AHashMap; use std::any::TypeId; -use std::collections::HashMap; use std::hash::Hash; /// Stores any object by `Key`. #[derive(Clone, Debug)] -pub struct AnyMap(HashMap); +pub struct AnyMap(AHashMap); impl Default for AnyMap { fn default() -> Self { - AnyMap(HashMap::new()) + AnyMap(AHashMap::new()) } } diff --git a/egui/src/any/serializable/any_map.rs b/egui/src/any/serializable/any_map.rs index 8fd10492..658a1594 100644 --- a/egui/src/any/serializable/any_map.rs +++ b/egui/src/any/serializable/any_map.rs @@ -1,16 +1,16 @@ use crate::any::serializable::element::{AnyMapElement, AnyMapTrait}; use crate::any::serializable::type_id::TypeId; +use crate::epaint::ahash::AHashMap; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use std::hash::Hash; /// Stores any object by `Key`, and can be de/serialized. #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct AnyMap(HashMap); +pub struct AnyMap(AHashMap); impl Default for AnyMap { fn default() -> Self { - AnyMap(HashMap::new()) + AnyMap(AHashMap::new()) } } diff --git a/egui/src/any/serializable/type_map.rs b/egui/src/any/serializable/type_map.rs index 87323033..124d9727 100644 --- a/egui/src/any/serializable/type_map.rs +++ b/egui/src/any/serializable/type_map.rs @@ -1,14 +1,14 @@ use crate::any::serializable::element::{AnyMapElement, AnyMapTrait}; use crate::any::serializable::type_id::TypeId; +use crate::epaint::ahash::AHashMap; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; /// Maps types to a single instance of that type. /// /// Used to store state per widget type. In effect a sort of singleton storage. /// Similar to [the `typemap` crate](https://docs.rs/typemap/0.3.3/typemap/) but allows serialization. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct TypeMap(HashMap); +pub struct TypeMap(AHashMap); // ---------------------------------------------------------------------------- diff --git a/egui/src/any/type_map.rs b/egui/src/any/type_map.rs index 2ed59c70..e4b89fa6 100644 --- a/egui/src/any/type_map.rs +++ b/egui/src/any/type_map.rs @@ -1,13 +1,13 @@ use crate::any::element::{AnyMapElement, AnyMapTrait}; +use crate::epaint::ahash::AHashMap; use std::any::TypeId; -use std::collections::HashMap; /// Maps types to a single instance of that type. /// /// Used to store state per widget type. In effect a sort of singleton storage. /// Similar to [the `typemap` crate](https://docs.rs/typemap/0.3.3/typemap/). #[derive(Clone, Debug, Default)] -pub struct TypeMap(HashMap); +pub struct TypeMap(AHashMap); // ----------------------------------------------------------------------------