diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 15c8dd2bb3e51..4183b615a999c 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -24,7 +24,7 @@ async-channel = "1.4" event-listener = "2.5" thread_local = "1.1.4" fixedbitset = "0.4.2" -fxhash = "0.2" +rustc-hash = "1.1" downcast-rs = "1.2" serde = { version = "1", features = ["derive"] } diff --git a/crates/bevy_ecs/src/archetype.rs b/crates/bevy_ecs/src/archetype.rs index 777dd0d2e3fcd..bd2ceb5dcc582 100644 --- a/crates/bevy_ecs/src/archetype.rs +++ b/crates/bevy_ecs/src/archetype.rs @@ -26,7 +26,6 @@ use crate::{ storage::{ImmutableSparseSet, SparseArray, SparseSet, SparseSetIndex, TableId, TableRow}, }; use std::{ - collections::HashMap, hash::Hash, ops::{Index, IndexMut}, }; @@ -601,7 +600,7 @@ impl SparseSetIndex for ArchetypeComponentId { pub struct Archetypes { pub(crate) archetypes: Vec, pub(crate) archetype_component_count: usize, - archetype_ids: HashMap, + archetype_ids: bevy_utils::HashMap, } impl Archetypes { diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index 042138a3c0db8..34d9b428ca2c1 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -12,10 +12,11 @@ use crate::{ component::{Component, ComponentId, ComponentStorage, Components, StorageType, Tick}, entity::{Entities, Entity, EntityLocation}, storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow}, + TypeIdMap, }; use bevy_ecs_macros::all_tuples; use bevy_ptr::OwningPtr; -use std::{any::TypeId, collections::HashMap}; +use std::any::TypeId; /// The `Bundle` trait enables insertion and removal of [`Component`]s from an entity. /// @@ -683,7 +684,7 @@ impl<'a, 'b> BundleSpawner<'a, 'b> { #[derive(Default)] pub struct Bundles { bundle_infos: Vec, - bundle_ids: HashMap, + bundle_ids: TypeIdMap, } impl Bundles { diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 745c75df6ff89..8d311686942b5 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -5,6 +5,7 @@ use crate::{ storage::{SparseSetIndex, Storages}, system::{Local, Resource}, world::{FromWorld, World}, + TypeIdMap, }; pub use bevy_ecs_macros::Component; use bevy_ptr::{OwningPtr, UnsafeCellDeref}; @@ -400,8 +401,8 @@ impl ComponentDescriptor { #[derive(Debug, Default)] pub struct Components { components: Vec, - indices: std::collections::HashMap, - resource_indices: std::collections::HashMap, + indices: TypeIdMap, + resource_indices: TypeIdMap, } impl Components { diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 77d6befc5d68d..38125d0b56dd5 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -19,6 +19,8 @@ pub mod storage; pub mod system; pub mod world; +use std::any::TypeId; + pub use bevy_ptr as ptr; /// Most commonly used re-exported types. @@ -52,6 +54,9 @@ pub mod prelude { pub use bevy_ecs_macros::all_tuples; +/// A specialized hashmap type with Key of `TypeId` +type TypeIdMap = rustc_hash::FxHashMap; + #[cfg(test)] mod tests { use crate as bevy_ecs;