Skip to content

Commit 9bc0ae3

Browse files
Move hashbrown and foldhash out of bevy_utils (#17460)
# Objective - Contributes to #16877 ## Solution - Moved `hashbrown`, `foldhash`, and related types out of `bevy_utils` and into `bevy_platform_support` - Refactored the above to match the layout of these types in `std`. - Updated crates as required. ## Testing - CI --- ## Migration Guide - The following items were moved out of `bevy_utils` and into `bevy_platform_support::hash`: - `FixedState` - `DefaultHasher` - `RandomState` - `FixedHasher` - `Hashed` - `PassHash` - `PassHasher` - `NoOpHash` - The following items were moved out of `bevy_utils` and into `bevy_platform_support::collections`: - `HashMap` - `HashSet` - `bevy_utils::hashbrown` has been removed. Instead, import from `bevy_platform_support::collections` _or_ take a dependency on `hashbrown` directly. - `bevy_utils::Entry` has been removed. Instead, import from `bevy_platform_support::collections::hash_map` or `bevy_platform_support::collections::hash_set` as appropriate. - All of the above equally apply to `bevy::utils` and `bevy::platform_support`. ## Notes - I left `PreHashMap`, `PreHashMapExt`, and `TypeIdMap` in `bevy_utils` as they might be candidates for micro-crating. They can always be moved into `bevy_platform_support` at a later date if desired.
1 parent 04990fc commit 9bc0ae3

File tree

175 files changed

+595
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+595
-443
lines changed

benches/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ bevy_reflect = { path = "../crates/bevy_reflect", features = ["functions"] }
2424
bevy_render = { path = "../crates/bevy_render" }
2525
bevy_tasks = { path = "../crates/bevy_tasks" }
2626
bevy_utils = { path = "../crates/bevy_utils" }
27+
bevy_platform_support = { path = "../crates/bevy_platform_support", default-features = false, features = [
28+
"std",
29+
] }
2730

2831
# Other crates
2932
glam = "0.29"

benches/benches/bevy_reflect/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use core::{fmt::Write, hint::black_box, iter, time::Duration};
22

33
use benches::bench;
4+
use bevy_platform_support::collections::HashMap;
45
use bevy_reflect::{DynamicMap, Map};
5-
use bevy_utils::HashMap;
66
use criterion::{
77
criterion_group, measurement::Measurement, AxisScale, BatchSize, BenchmarkGroup, BenchmarkId,
88
Criterion, PlotConfiguration, Throughput,

crates/bevy_animation/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ bevy_time = { path = "../bevy_time", version = "0.16.0-dev" }
2525
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" }
2626
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
2727
bevy_transform = { path = "../bevy_transform", version = "0.16.0-dev" }
28+
bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-dev", default-features = false, features = [
29+
"std",
30+
"serialize",
31+
] }
2832

2933
# other
3034
petgraph = { version = "0.6", features = ["serde-1"] }

crates/bevy_animation/src/animation_curves.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,20 @@ use core::{
8989
marker::PhantomData,
9090
};
9191

92+
use crate::{
93+
graph::AnimationNodeIndex,
94+
prelude::{Animatable, BlendInput},
95+
AnimationEntityMut, AnimationEvaluationError,
96+
};
9297
use bevy_ecs::component::{Component, Mutable};
9398
use bevy_math::curve::{
9499
cores::{UnevenCore, UnevenCoreError},
95100
iterable::IterableCurve,
96101
Curve, Interval,
97102
};
103+
use bevy_platform_support::hash::Hashed;
98104
use bevy_reflect::{FromReflect, Reflect, Reflectable, TypeInfo, Typed};
99105
use bevy_render::mesh::morph::MorphWeights;
100-
101-
use crate::{
102-
graph::AnimationNodeIndex,
103-
prelude::{Animatable, BlendInput},
104-
AnimationEntityMut, AnimationEvaluationError,
105-
};
106-
use bevy_utils::Hashed;
107106
use downcast_rs::{impl_downcast, Downcast};
108107

109108
/// A value on a component that Bevy can animate.

crates/bevy_animation/src/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use bevy_ecs::{
1717
resource::Resource,
1818
system::{Res, ResMut},
1919
};
20+
use bevy_platform_support::collections::HashMap;
2021
use bevy_reflect::{prelude::ReflectDefault, Reflect, ReflectSerialize};
21-
use bevy_utils::HashMap;
2222
use derive_more::derive::From;
2323
use petgraph::{
2424
graph::{DiGraph, NodeIndex},

crates/bevy_animation/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ use bevy_ecs::{
4040
world::EntityMutExcept,
4141
};
4242
use bevy_math::FloatOrd;
43+
use bevy_platform_support::{collections::HashMap, hash::NoOpHash};
4344
use bevy_reflect::{prelude::ReflectDefault, Reflect, TypePath};
4445
use bevy_time::Time;
4546
use bevy_transform::TransformSystem;
46-
use bevy_utils::{HashMap, NoOpHash, PreHashMap, PreHashMapExt, TypeIdMap};
47+
use bevy_utils::{PreHashMap, PreHashMapExt, TypeIdMap};
4748
use petgraph::graph::NodeIndex;
4849
use serde::{Deserialize, Serialize};
4950
use thread_local::ThreadLocal;
@@ -754,10 +755,10 @@ impl AnimationCurveEvaluators {
754755
.component_property_curve_evaluators
755756
.get_or_insert_with(component_property, func),
756757
EvaluatorId::Type(type_id) => match self.type_id_curve_evaluators.entry(type_id) {
757-
bevy_utils::hashbrown::hash_map::Entry::Occupied(occupied_entry) => {
758+
bevy_platform_support::collections::hash_map::Entry::Occupied(occupied_entry) => {
758759
&mut **occupied_entry.into_mut()
759760
}
760-
bevy_utils::hashbrown::hash_map::Entry::Vacant(vacant_entry) => {
761+
bevy_platform_support::collections::hash_map::Entry::Vacant(vacant_entry) => {
761762
&mut **vacant_entry.insert(func())
762763
}
763764
},

crates/bevy_app/src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bevy_ecs::{
1616
schedule::{ScheduleBuildSettings, ScheduleLabel},
1717
system::{IntoObserverSystem, SystemId, SystemInput},
1818
};
19-
use bevy_utils::HashMap;
19+
use bevy_platform_support::collections::HashMap;
2020
use core::{fmt::Debug, num::NonZero, panic::AssertUnwindSafe};
2121
use log::debug;
2222
use thiserror::Error;

crates/bevy_app/src/plugin_group.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use alloc::{
44
string::{String, ToString},
55
vec::Vec,
66
};
7-
use bevy_utils::{hashbrown::hash_map::Entry, TypeIdMap};
7+
use bevy_platform_support::collections::hash_map::Entry;
8+
use bevy_utils::TypeIdMap;
89
use core::any::TypeId;
910
use log::{debug, warn};
1011

crates/bevy_app/src/sub_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_ecs::{
66
schedule::{InternedScheduleLabel, ScheduleBuildSettings, ScheduleLabel},
77
system::{SystemId, SystemInput},
88
};
9-
use bevy_utils::{HashMap, HashSet};
9+
use bevy_platform_support::collections::{HashMap, HashSet};
1010
use core::fmt::Debug;
1111

1212
#[cfg(feature = "trace")]

crates/bevy_asset/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [
2727
] }
2828
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev" }
2929
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" }
30+
bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-dev", default-features = false, features = [
31+
"std",
32+
] }
3033

3134
stackfuture = "0.3"
3235
atomicow = "1.0"

0 commit comments

Comments
 (0)