Skip to content

Commit

Permalink
Update hashbrown to 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
LoweredgamesDev authored and clarfonthey committed Oct 9, 2024
1 parent 6d4ac45 commit 1f86e6e
Show file tree
Hide file tree
Showing 55 changed files with 205 additions and 142 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl AnimationGraph {
Self {
graph,
root,
mask_groups: HashMap::new(),
mask_groups: HashMap::default(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl App {
Self {
sub_apps: SubApps {
main: SubApp::new(),
sub_apps: HashMap::new(),
sub_apps: HashMap::default(),
},
runner: Box::new(run_once),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/gated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<R: AssetReader> GatedReader<R> {
/// Creates a new [`GatedReader`], which wraps the given `reader`. Also returns a [`GateOpener`] which
/// can be used to open "path gates" for this [`GatedReader`].
pub fn new(reader: R) -> (Self, GateOpener) {
let gates = Arc::new(RwLock::new(HashMap::new()));
let gates = Arc::new(RwLock::new(HashMap::default()));
(
Self {
reader,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl AssetSourceBuilders {
/// Builds a new [`AssetSources`] collection. If `watch` is true, the unprocessed sources will watch for changes.
/// If `watch_processed` is true, the processed sources will watch for changes.
pub fn build_sources(&mut self, watch: bool, watch_processed: bool) -> AssetSources {
let mut sources = HashMap::new();
let mut sources = HashMap::default();
for (id, source) in &mut self.sources {
if let Some(data) = source.build(
AssetSourceId::Name(id.clone_owned()),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct LoadedAsset<A: Asset> {
impl<A: Asset> LoadedAsset<A> {
/// Create a new loaded asset. This will use [`VisitAssetDependencies`](crate::VisitAssetDependencies) to populate `dependencies`.
pub fn new_with_dependencies(value: A, meta: Option<Box<dyn AssetMetaDyn>>) -> Self {
let mut dependencies = HashSet::new();
let mut dependencies = HashSet::default();
value.visit_dependencies(&mut |id| {
dependencies.insert(id);
});
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/server/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ impl AssetInfos {

loaded_asset.value.insert(loaded_asset_id, world);
let mut loading_deps = loaded_asset.dependencies;
let mut failed_deps = HashSet::new();
let mut failed_deps = HashSet::default();
let mut dep_error = None;
let mut loading_rec_deps = loading_deps.clone();
let mut failed_rec_deps = HashSet::new();
let mut failed_rec_deps = HashSet::default();
let mut rec_dep_error = None;
loading_deps.retain(|dep_id| {
if let Some(dep_info) = self.get_mut(*dep_id) {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ pub fn handle_internal_asset_events(world: &mut World) {
}
};

let mut paths_to_reload = HashSet::new();
let mut paths_to_reload = HashSet::default();
let mut handle_event = |source: AssetSourceId<'static>, event: AssetSourceEvent| {
match event {
// TODO: if the asset was processed and the processed file was changed, the first modified event
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/upscaling/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn prepare_view_upscaling_pipelines(
blit_pipeline: Res<BlitPipeline>,
view_targets: Query<(Entity, &ViewTarget, Option<&ExtractedCamera>)>,
) {
let mut output_textures = HashSet::new();
let mut output_textures = HashSet::default();
for (entity, view_target, camera) in view_targets.iter() {
let out_texture_id = view_target.out_texture().id();
let blend_state = if let Some(ExtractedCamera {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_dev_tools/src/ui_debug_overlay/inset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct DrawnLines {
impl DrawnLines {
fn new(width: f32) -> Self {
DrawnLines {
lines: HashMap::new(),
lines: HashMap::default(),
width,
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl Archetype {
// component in the `table_components` vector
component_index
.entry(component_id)
.or_insert_with(HashMap::new)
.or_default()
.insert(id, ArchetypeRecord { column: Some(idx) });
}

Expand All @@ -420,7 +420,7 @@ impl Archetype {
);
component_index
.entry(component_id)
.or_insert_with(HashMap::new)
.or_default()
.insert(id, ArchetypeRecord { column: None });
}
Self {
Expand Down
9 changes: 6 additions & 3 deletions crates/bevy_ecs/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl BundleInfo {

if deduped.len() != component_ids.len() {
// TODO: Replace with `Vec::partition_dedup` once https://github.com/rust-lang/rust/issues/54279 is stabilized
let mut seen = HashSet::new();
let mut seen = HashSet::default();
let mut dups = Vec::new();
for id in component_ids {
if !seen.insert(id) {
Expand Down Expand Up @@ -1422,8 +1422,11 @@ impl Bundles {
.or_insert_with(|| {
let (id, storages) =
initialize_dynamic_bundle(bundle_infos, components, Vec::from(component_ids));
self.dynamic_bundle_storages
.insert_unique_unchecked(id, storages);
// SAFETY: We know the ID is unique
unsafe {
self.dynamic_bundle_storages
.insert_unique_unchecked(id, storages);
}
(component_ids.into(), id)
});
*bundle_id
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/entity/visit_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ mod tests {
let mut entity_map = EntityHashMap::<Entity>::default();
let mut remapped = Foo {
ordered: vec![],
unordered: HashSet::new(),
unordered: HashSet::default(),
single: Entity::PLACEHOLDER,
not_an_entity: foo.not_an_entity.clone(),
};
Expand Down
90 changes: 62 additions & 28 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ mod tests {
let mut world = World::new();
let e = world.spawn((TableStored("abc"), A(123))).id();
let f = world.spawn((TableStored("def"), A(456), B(1))).id();
let mut results = HashSet::new();
let mut results = HashSet::default();
world
.query::<(Entity, &A)>()
.iter(&world)
Expand Down Expand Up @@ -594,7 +594,9 @@ mod tests {
.collect::<HashSet<_>>();
assert_eq!(
ents,
HashSet::from([(e, None, A(123)), (f, Some(SparseStored(1)), A(456))])
([(e, None, A(123)), (f, Some(SparseStored(1)), A(456))])
.into_iter()
.collect::<HashSet<_>>()
);
}

Expand Down Expand Up @@ -626,7 +628,9 @@ mod tests {
.iter(&world)
.map(|(e, &i, &b)| (e, i, b))
.collect::<HashSet<_>>(),
HashSet::from([(e1, A(1), B(3)), (e2, A(2), B(4))])
([(e1, A(1), B(3)), (e2, A(2), B(4))])
.into_iter()
.collect::<HashSet<_>>()
);
assert_eq!(world.entity_mut(e1).take::<A>(), Some(A(1)));
assert_eq!(
Expand All @@ -643,7 +647,9 @@ mod tests {
.iter(&world)
.map(|(e, &B(b), &TableStored(s))| (e, b, s))
.collect::<HashSet<_>>(),
HashSet::from([(e2, 4, "xyz"), (e1, 3, "abc")])
([(e2, 4, "xyz"), (e1, 3, "abc")])
.into_iter()
.collect::<HashSet<_>>()
);
world.entity_mut(e1).insert(A(43));
assert_eq!(
Expand All @@ -652,7 +658,9 @@ mod tests {
.iter(&world)
.map(|(e, &i, &b)| (e, i, b))
.collect::<HashSet<_>>(),
HashSet::from([(e2, A(2), B(4)), (e1, A(43), B(3))])
([(e2, A(2), B(4)), (e1, A(43), B(3))])
.into_iter()
.collect::<HashSet<_>>()
);
world.entity_mut(e1).insert(C);
assert_eq!(
Expand Down Expand Up @@ -950,15 +958,15 @@ mod tests {

assert_eq!(
get_filtered::<Changed<A>>(&mut world),
HashSet::from([e1, e3])
([e1, e3]).into_iter().collect::<HashSet<_>>()
);

// ensure changing an entity's archetypes also moves its changed state
world.entity_mut(e1).insert(C);

assert_eq!(
get_filtered::<Changed<A>>(&mut world),
HashSet::from([e3, e1]),
([e3, e1]).into_iter().collect::<HashSet<_>>(),
"changed entities list should not change"
);

Expand All @@ -967,23 +975,23 @@ mod tests {

assert_eq!(
get_filtered::<Changed<A>>(&mut world),
HashSet::from([e3, e1]),
([e3, e1]).into_iter().collect::<HashSet<_>>(),
"changed entities list should not change"
);

// removing an unchanged entity should not change changed state
assert!(world.despawn(e2));
assert_eq!(
get_filtered::<Changed<A>>(&mut world),
HashSet::from([e3, e1]),
([e3, e1]).into_iter().collect::<HashSet<_>>(),
"changed entities list should not change"
);

// removing a changed entity should remove it from enumeration
assert!(world.despawn(e1));
assert_eq!(
get_filtered::<Changed<A>>(&mut world),
HashSet::from([e3]),
([e3]).into_iter().collect::<HashSet<_>>(),
"e1 should no longer be returned"
);

Expand All @@ -994,11 +1002,20 @@ mod tests {
let e4 = world.spawn_empty().id();

world.entity_mut(e4).insert(A(0));
assert_eq!(get_filtered::<Changed<A>>(&mut world), HashSet::from([e4]));
assert_eq!(get_filtered::<Added<A>>(&mut world), HashSet::from([e4]));
assert_eq!(
get_filtered::<Changed<A>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);
assert_eq!(
get_filtered::<Added<A>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);

world.entity_mut(e4).insert(A(1));
assert_eq!(get_filtered::<Changed<A>>(&mut world), HashSet::from([e4]));
assert_eq!(
get_filtered::<Changed<A>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);

world.clear_trackers();

Expand All @@ -1007,9 +1024,18 @@ mod tests {
world.entity_mut(e4).insert((A(0), B(0)));

assert!(get_filtered::<Added<A>>(&mut world).is_empty());
assert_eq!(get_filtered::<Changed<A>>(&mut world), HashSet::from([e4]));
assert_eq!(get_filtered::<Added<B>>(&mut world), HashSet::from([e4]));
assert_eq!(get_filtered::<Changed<B>>(&mut world), HashSet::from([e4]));
assert_eq!(
get_filtered::<Changed<A>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);
assert_eq!(
get_filtered::<Added<B>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);
assert_eq!(
get_filtered::<Changed<B>>(&mut world),
([e4]).into_iter().collect::<HashSet<_>>()
);
}

#[test]
Expand Down Expand Up @@ -1041,35 +1067,35 @@ mod tests {

assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e1, e3])
([e1, e3]).into_iter().collect::<HashSet<_>>()
);

// ensure changing an entity's archetypes also moves its changed state
world.entity_mut(e1).insert(C);

assert_eq!(get_filtered::<Changed<SparseStored>>(&mut world), HashSet::from([e3, e1]), "changed entities list should not change (although the order will due to archetype moves)");
assert_eq!(get_filtered::<Changed<SparseStored>>(&mut world), ([e3, e1]).into_iter().collect::<HashSet<_>>(), "changed entities list should not change (although the order will due to archetype moves)");

// spawning a new SparseStored entity should not change existing changed state
world.entity_mut(e1).insert(SparseStored(0));
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e3, e1]),
([e3, e1]).into_iter().collect::<HashSet<_>>(),
"changed entities list should not change"
);

// removing an unchanged entity should not change changed state
assert!(world.despawn(e2));
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e3, e1]),
([e3, e1]).into_iter().collect::<HashSet<_>>(),
"changed entities list should not change"
);

// removing a changed entity should remove it from enumeration
assert!(world.despawn(e1));
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e3]),
([e3]).into_iter().collect::<HashSet<_>>(),
"e1 should no longer be returned"
);

Expand All @@ -1082,17 +1108,17 @@ mod tests {
world.entity_mut(e4).insert(SparseStored(0));
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e4])
([e4]).into_iter().collect::<HashSet<_>>()
);
assert_eq!(
get_filtered::<Added<SparseStored>>(&mut world),
HashSet::from([e4])
([e4]).into_iter().collect::<HashSet<_>>()
);

world.entity_mut(e4).insert(A(1));
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e4])
([e4]).into_iter().collect::<HashSet<_>>()
);

world.clear_trackers();
Expand All @@ -1104,7 +1130,7 @@ mod tests {
assert!(get_filtered::<Added<SparseStored>>(&mut world).is_empty());
assert_eq!(
get_filtered::<Changed<SparseStored>>(&mut world),
HashSet::from([e4])
([e4]).into_iter().collect::<HashSet<_>>()
);
}

Expand Down Expand Up @@ -1288,7 +1314,12 @@ mod tests {
.iter(&world)
.map(|(a, b)| (a.0, b.0))
.collect::<HashSet<_>>();
assert_eq!(results, HashSet::from([(1, "1"), (2, "2"), (3, "3"),]));
assert_eq!(
results,
([(1, "1"), (2, "2"), (3, "3"),])
.into_iter()
.collect::<HashSet<_>>()
);

let removed_bundle = world.entity_mut(e2).take::<(B, TableStored)>().unwrap();
assert_eq!(removed_bundle, (B(2), TableStored("2")));
Expand All @@ -1297,11 +1328,14 @@ mod tests {
.iter(&world)
.map(|(a, b)| (a.0, b.0))
.collect::<HashSet<_>>();
assert_eq!(results, HashSet::from([(1, "1"), (3, "3"),]));
assert_eq!(
results,
([(1, "1"), (3, "3"),]).into_iter().collect::<HashSet<_>>()
);

let mut a_query = world.query::<&A>();
let results = a_query.iter(&world).map(|a| a.0).collect::<HashSet<_>>();
assert_eq!(results, HashSet::from([1, 3, 2]));
assert_eq!(results, ([1, 3, 2]).into_iter().collect::<HashSet<_>>());

let entity_ref = world.entity(e2);
assert_eq!(
Expand Down
Loading

0 comments on commit 1f86e6e

Please sign in to comment.