Switch usage of std HashMap/HashSet default hasher, to aHash algo (#258)

switch to ahash for HashMaps and HashSets via a new bevy_utils crate
This commit is contained in:
Robbie Davenport 2020-08-29 09:08:51 +09:00 committed by GitHub
parent c40e29bca3
commit 4aabe983ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 153 additions and 101 deletions

View File

@ -57,6 +57,7 @@ bevy_sprite = { path = "crates/bevy_sprite", version = "0.1" }
bevy_transform = { path = "crates/bevy_transform", version = "0.1" } bevy_transform = { path = "crates/bevy_transform", version = "0.1" }
bevy_text = { path = "crates/bevy_text", version = "0.1" } bevy_text = { path = "crates/bevy_text", version = "0.1" }
bevy_ui = { path = "crates/bevy_ui", version = "0.1" } bevy_ui = { path = "crates/bevy_ui", version = "0.1" }
bevy_utils = { path = "crates/bevy_utils", version = "0.1" }
bevy_window = { path = "crates/bevy_window", version = "0.1" } bevy_window = { path = "crates/bevy_window", version = "0.1" }
# bevy (optional) # bevy (optional)

View File

@ -19,6 +19,7 @@ bevy_app = { path = "../bevy_app", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_property = { path = "../bevy_property", version = "0.1" } bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
uuid = { version = "0.8", features = ["v4", "serde"] } uuid = { version = "0.8", features = ["v4", "serde"] }

View File

@ -4,10 +4,10 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use bevy_ecs::{Res, Resource, Resources}; use bevy_ecs::{Res, Resource, Resources};
use bevy_utils::{HashMap, HashSet};
use crossbeam_channel::TryRecvError; use crossbeam_channel::TryRecvError;
use parking_lot::RwLock; use parking_lot::RwLock;
use std::{ use std::{
collections::{HashMap, HashSet},
env, fs, io, env, fs, io,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc, sync::Arc,
@ -185,7 +185,7 @@ impl AssetServer {
#[cfg(feature = "filesystem_watcher")] #[cfg(feature = "filesystem_watcher")]
pub fn filesystem_watcher_system(asset_server: Res<AssetServer>) { pub fn filesystem_watcher_system(asset_server: Res<AssetServer>) {
use notify::event::{Event, EventKind, ModifyKind}; use notify::event::{Event, EventKind, ModifyKind};
let mut changed = HashSet::new(); let mut changed = HashSet::default();
while let Some(filesystem_watcher) = asset_server.filesystem_watcher.read().as_ref() { while let Some(filesystem_watcher) = asset_server.filesystem_watcher.read().as_ref() {
let result = match filesystem_watcher.receiver.try_recv() { let result = match filesystem_watcher.receiver.try_recv() {

View File

@ -5,7 +5,7 @@ use crate::{
use bevy_app::{prelude::Events, AppBuilder}; use bevy_app::{prelude::Events, AppBuilder};
use bevy_ecs::{FromResources, IntoQuerySystem, ResMut, Resource}; use bevy_ecs::{FromResources, IntoQuerySystem, ResMut, Resource};
use bevy_type_registry::RegisterType; use bevy_type_registry::RegisterType;
use std::collections::HashMap; use bevy_utils::HashMap;
/// Events that happen on assets of type `T` /// Events that happen on assets of type `T`
pub enum AssetEvent<T: Resource> { pub enum AssetEvent<T: Resource> {

View File

@ -15,4 +15,5 @@ bevy_derive = { path = "../bevy_derive", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_property = { path = "../bevy_property", version = "0.1" } bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }

View File

@ -1,8 +1,8 @@
use bevy_ecs::prelude::*; use bevy_ecs::prelude::*;
use bevy_property::Properties; use bevy_property::Properties;
use bevy_utils::{HashMap, HashSet};
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::{HashMap, HashSet},
fmt::Debug, fmt::Debug,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
@ -29,7 +29,7 @@ where
T: IntoIterator<Item = L>, T: IntoIterator<Item = L>,
{ {
fn from(value: T) -> Self { fn from(value: T) -> Self {
let mut labels = HashSet::new(); let mut labels = HashSet::default();
for label in value { for label in value {
labels.insert(label.into()); labels.insert(label.into());
} }

View File

@ -17,7 +17,8 @@ profiler = ["bevy_ecs/profiler"]
bevy_app = { path = "../bevy_app", version = "0.1" } bevy_app = { path = "../bevy_app", version = "0.1" }
bevy_core = { path = "../bevy_core", version = "0.1" } bevy_core = { path = "../bevy_core", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
uuid = { version = "0.8", features = ["v4", "serde"] } uuid = { version = "0.8", features = ["v4", "serde"] }
parking_lot = "0.10" parking_lot = "0.10"

View File

@ -1,5 +1,6 @@
use bevy_utils::HashMap;
use std::{ use std::{
collections::{HashMap, VecDeque}, collections::VecDeque,
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}; };
use uuid::Uuid; use uuid::Uuid;

View File

@ -1,7 +1,8 @@
use crate::{Diagnostic, DiagnosticId, Diagnostics}; use crate::{Diagnostic, DiagnosticId, Diagnostics};
use bevy_ecs::{Profiler, Res, ResMut}; use bevy_ecs::{Profiler, Res, ResMut};
use bevy_utils::HashMap;
use parking_lot::RwLock; use parking_lot::RwLock;
use std::{borrow::Cow, collections::HashMap, sync::Arc, time::Instant}; use std::{borrow::Cow, sync::Arc, time::Instant};
#[derive(Debug)] #[derive(Debug)]
struct SystemRunInfo { struct SystemRunInfo {

View File

@ -15,6 +15,7 @@ profiler = []
[dependencies] [dependencies]
bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.1" } bevy_hecs = { path = "hecs", features = ["macros", "serialize"], version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
rand = "0.7.2" rand = "0.7.2"
rayon = "1.3" rayon = "1.3"
crossbeam-channel = "0.4.2" crossbeam-channel = "0.4.2"

View File

@ -28,7 +28,7 @@ serialize = ["serde"]
[dependencies] [dependencies]
bevy_hecs_macros = { path = "macros", version = "0.1.3", optional = true } bevy_hecs_macros = { path = "macros", version = "0.1.3", optional = true }
hashbrown = { version = "0.8.0", default-features = false, features = ["ahash", "inline-more"] } bevy_utils = { path = "../../bevy_utils", version = "0.1" }
lazy_static = { version = "1.4.0", optional = true, features = ["spin_no_std"] } lazy_static = { version = "1.4.0", optional = true, features = ["spin_no_std"] }
serde = { version = "1", features = ["derive"], optional = true} serde = { version = "1", features = ["derive"], optional = true}
rand = "0.7.3" rand = "0.7.3"

View File

@ -83,7 +83,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
#path::lazy_static::lazy_static! { #path::lazy_static::lazy_static! {
static ref ELEMENTS: [TypeId; #n] = { static ref ELEMENTS: [TypeId; #n] = {
let mut dedup = std::collections::HashSet::new(); let mut dedup = #path::bevy_utils::HashSet::default();
for &(ty, name) in [#((std::any::TypeId::of::<#tys>(), std::any::type_name::<#tys>())),*].iter() { for &(ty, name) in [#((std::any::TypeId::of::<#tys>(), std::any::type_name::<#tys>())),*].iter() {
if !dedup.insert(ty) { if !dedup.insert(ty) {
panic!("{} has multiple {} fields; each type must occur at most once!", stringify!(#ident), name); panic!("{} has multiple {} fields; each type must occur at most once!", stringify!(#ident), name);

View File

@ -20,6 +20,7 @@ use crate::alloc::{
vec, vec,
vec::Vec, vec::Vec,
}; };
use bevy_utils::{HashMap, HashMapExt};
use core::{ use core::{
any::{type_name, TypeId}, any::{type_name, TypeId},
cell::UnsafeCell, cell::UnsafeCell,
@ -27,8 +28,6 @@ use core::{
ptr::{self, NonNull}, ptr::{self, NonNull},
}; };
use hashbrown::HashMap;
use crate::{borrow::AtomicBorrow, query::Fetch, Access, Component, Query}; use crate::{borrow::AtomicBorrow, query::Fetch, Access, Component, Query};
/// A collection of entities having the same component types /// A collection of entities having the same component types

View File

@ -1,7 +1,7 @@
// modified by Bevy contributors // modified by Bevy contributors
use bevy_utils::HashMap;
use core::fmt; use core::fmt;
use hashbrown::HashMap;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::error::Error; use std::error::Error;

View File

@ -20,14 +20,14 @@ use crate::alloc::{
vec, vec,
vec::Vec, vec::Vec,
}; };
use bevy_utils::HashSet;
use core::{ use core::{
any::TypeId, any::TypeId,
mem::{self, MaybeUninit}, mem::{self, MaybeUninit},
ptr, ptr,
}; };
use hashbrown::HashSet;
use crate::{archetype::TypeInfo, Component, DynamicBundle}; use crate::{archetype::TypeInfo, Component, DynamicBundle};
/// Helper for incrementally constructing a bundle of components with dynamic component types /// Helper for incrementally constructing a bundle of components with dynamic component types
@ -59,7 +59,7 @@ impl EntityBuilder {
storage: Box::new([]), storage: Box::new([]),
info: Vec::new(), info: Vec::new(),
ids: Vec::new(), ids: Vec::new(),
id_set: HashSet::new(), id_set: HashSet::default(),
} }
} }

View File

@ -89,6 +89,8 @@ pub use world::{ArchetypesGeneration, Component, ComponentError, Iter, SpawnBatc
// Unstable implementation details needed by the macros // Unstable implementation details needed by the macros
#[doc(hidden)] #[doc(hidden)]
pub use archetype::TypeInfo; pub use archetype::TypeInfo;
#[doc(hidden)]
pub use bevy_utils;
#[cfg(feature = "macros")] #[cfg(feature = "macros")]
#[doc(hidden)] #[doc(hidden)]
pub use lazy_static; pub use lazy_static;

View File

@ -15,13 +15,12 @@
// modified by Bevy contributors // modified by Bevy contributors
use crate::alloc::vec::Vec; use crate::alloc::vec::Vec;
use bevy_utils::{HashMap, HashSet};
use core::{any::TypeId, convert::TryFrom, fmt, mem, ptr}; use core::{any::TypeId, convert::TryFrom, fmt, mem, ptr};
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::error::Error; use std::error::Error;
use hashbrown::{HashMap, HashSet};
use crate::{ use crate::{
archetype::Archetype, archetype::Archetype,
entities::{Entities, Location}, entities::{Entities, Location},
@ -363,7 +362,7 @@ impl World {
entity: Entity, entity: Entity,
components: impl DynamicBundle, components: impl DynamicBundle,
) -> Result<(), NoSuchEntity> { ) -> Result<(), NoSuchEntity> {
use hashbrown::hash_map::Entry; use std::collections::hash_map::Entry;
let loc = self.entities.get_mut(entity)?; let loc = self.entities.get_mut(entity)?;
unsafe { unsafe {
@ -461,7 +460,7 @@ impl World {
/// assert_eq!(*world.get::<bool>(e).unwrap(), true); /// assert_eq!(*world.get::<bool>(e).unwrap(), true);
/// ``` /// ```
pub fn remove<T: Bundle>(&mut self, entity: Entity) -> Result<T, ComponentError> { pub fn remove<T: Bundle>(&mut self, entity: Entity) -> Result<T, ComponentError> {
use hashbrown::hash_map::Entry; use std::collections::hash_map::Entry;
let loc = self.entities.get_mut(entity)?; let loc = self.entities.get_mut(entity)?;
unsafe { unsafe {

View File

@ -1,8 +1,9 @@
use super::{FetchResource, ResourceQuery}; use super::{FetchResource, ResourceQuery};
use crate::system::SystemId; use crate::system::SystemId;
use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo}; use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo};
use bevy_utils::HashMap;
use core::any::TypeId; use core::any::TypeId;
use std::{collections::HashMap, ptr::NonNull}; use std::ptr::NonNull;
/// A Resource type /// A Resource type
pub trait Resource: Send + Sync + 'static {} pub trait Resource: Send + Sync + 'static {}
@ -64,7 +65,7 @@ impl Resources {
ResourceData { ResourceData {
archetype: Archetype::new(types), archetype: Archetype::new(types),
default_index: None, default_index: None,
system_id_to_archetype_index: HashMap::new(), system_id_to_archetype_index: HashMap::default(),
} }
}); });

View File

@ -4,12 +4,9 @@ use crate::{
system::{System, SystemId, ThreadLocalExecution}, system::{System, SystemId, ThreadLocalExecution},
}; };
use bevy_hecs::World; use bevy_hecs::World;
use bevy_utils::{HashMap, HashSet};
use parking_lot::Mutex; use parking_lot::Mutex;
use std::{ use std::{borrow::Cow, sync::Arc};
borrow::Cow,
collections::{HashMap, HashSet},
sync::Arc,
};
/// An ordered collection of stages, which each contain an ordered list of [System]s. /// An ordered collection of stages, which each contain an ordered list of [System]s.
/// Schedules are essentially the "execution plan" for an App's systems. /// Schedules are essentially the "execution plan" for an App's systems.

View File

@ -1,7 +1,8 @@
use crate::resource::Resources; use crate::resource::Resources;
use bevy_hecs::{Access, Query, World}; use bevy_hecs::{Access, Query, World};
use bevy_utils::HashSet;
use fixedbitset::FixedBitSet; use fixedbitset::FixedBitSet;
use std::{any::TypeId, borrow::Cow, collections::HashSet}; use std::{any::TypeId, borrow::Cow};
/// Determines the strategy used to run the `run_thread_local` function in a [System] /// Determines the strategy used to run the `run_thread_local` function in a [System]
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]

View File

@ -14,7 +14,11 @@ default = []
serialize = ["serde"] serialize = ["serde"]
[dependencies] [dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.1" } bevy_app = { path = "../bevy_app", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }

View File

@ -1,4 +1,5 @@
use std::{collections::HashSet, hash::Hash}; use bevy_utils::HashSet;
use std::hash::Hash;
/// A "press-able" input of type `T` /// A "press-able" input of type `T`
pub struct Input<T> { pub struct Input<T> {

View File

@ -14,9 +14,10 @@ keywords = ["bevy"]
bevy_ecs = {path = "../bevy_ecs", version = "0.1"} bevy_ecs = {path = "../bevy_ecs", version = "0.1"}
bevy_math = {path = "../bevy_math", version = "0.1"} bevy_math = {path = "../bevy_math", version = "0.1"}
bevy_property_derive = {path = "bevy_property_derive", version = "0.1"} bevy_property_derive = {path = "bevy_property_derive", version = "0.1"}
bevy_utils = {path = "../bevy_utils", version = "0.1"}
# other # other
erased-serde = "0.3" erased-serde = "0.3"
bevy_ron = {path = "../bevy_ron", version = "0.1.3"} bevy_ron = {path = "../bevy_ron", version = "0.1.3"}
serde = "1" serde = "1"
smallvec = {version = "1.4", features = ["serde"]} smallvec = {version = "1.4", features = ["serde"]}

View File

@ -2,8 +2,9 @@ use crate::{
property_serde::{DynamicPropertiesDeserializer, DynamicPropertiesSerializer, Serializable}, property_serde::{DynamicPropertiesDeserializer, DynamicPropertiesSerializer, Serializable},
DeserializeProperty, Properties, Property, PropertyIter, PropertyType, PropertyTypeRegistry, DeserializeProperty, Properties, Property, PropertyIter, PropertyType, PropertyTypeRegistry,
}; };
use bevy_utils::HashMap;
use serde::de::DeserializeSeed; use serde::de::DeserializeSeed;
use std::{any::Any, borrow::Cow, collections::HashMap}; use std::{any::Any, borrow::Cow};
pub struct DynamicProperties { pub struct DynamicProperties {
pub type_name: String, pub type_name: String,

View File

@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use std::{ use std::{
any::Any, any::Any,
collections::{BTreeMap, HashMap, HashSet}, collections::{BTreeMap, HashMap, HashSet},
hash::Hash, hash::{BuildHasher, Hash},
ops::Range, ops::Range,
}; };
@ -105,10 +105,11 @@ where
// impl_property!(SEQUENCE, VecDeque<T> where T: Clone + Send + Sync + Serialize + 'static); // impl_property!(SEQUENCE, VecDeque<T> where T: Clone + Send + Sync + Serialize + 'static);
impl_property!(Option<T> where T: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static); impl_property!(Option<T> where T: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static);
impl_property!(HashSet<T> where T: Clone + Eq + Send + Sync + Hash + Serialize + for<'de> Deserialize<'de> + 'static); impl_property!(HashSet<T, H> where T: Clone + Eq + Send + Sync + Hash + Serialize + for<'de> Deserialize<'de> + 'static, H: Clone + Send + Sync + Default + BuildHasher + 'static);
impl_property!(HashMap<K, V> where impl_property!(HashMap<K, V, H> where
K: Clone + Eq + Send + Sync + Hash + Serialize + for<'de> Deserialize<'de> + 'static, K: Clone + Eq + Send + Sync + Hash + Serialize + for<'de> Deserialize<'de> + 'static,
V: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static,); V: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static,
H: Clone + Send + Sync + Default + BuildHasher + 'static);
impl_property!(BTreeMap<K, V> where impl_property!(BTreeMap<K, V> where
K: Clone + Ord + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static, K: Clone + Ord + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static,
V: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static); V: Clone + Send + Sync + Serialize + for<'de> Deserialize<'de> + 'static);

View File

@ -1,8 +1,6 @@
use crate::{DeserializeProperty, Property}; use crate::{DeserializeProperty, Property};
use std::{ use bevy_utils::{HashMap, HashSet};
any::TypeId, use std::any::TypeId;
collections::{HashMap, HashSet},
};
#[derive(Default)] #[derive(Default)]
pub struct PropertyTypeRegistry { pub struct PropertyTypeRegistry {

View File

@ -21,6 +21,7 @@ bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_transform = { path = "../bevy_transform", version = "0.1" } bevy_transform = { path = "../bevy_transform", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_window = { path = "../bevy_window", version = "0.1" } bevy_window = { path = "../bevy_window", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# rendering # rendering
spirv-reflect = "0.2.3" spirv-reflect = "0.2.3"

View File

@ -1,6 +1,7 @@
use super::Batch; use super::Batch;
use bevy_utils::HashMap;
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
use std::{borrow::Cow, collections::HashMap, hash::Hash}; use std::{borrow::Cow, hash::Hash};
// TODO: add sorting by primary / secondary handle to reduce rebinds of data // TODO: add sorting by primary / secondary handle to reduce rebinds of data

View File

@ -1,6 +1,6 @@
use super::Camera; use super::Camera;
use bevy_ecs::{Entity, Query, ResMut}; use bevy_ecs::{Entity, Query, ResMut};
use std::collections::HashMap; use bevy_utils::HashMap;
#[derive(Default)] #[derive(Default)]
pub struct ActiveCameras { pub struct ActiveCameras {

View File

@ -11,7 +11,8 @@ use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_core::AsBytes; use bevy_core::AsBytes;
use bevy_ecs::{Local, Query, Res, ResMut}; use bevy_ecs::{Local, Query, Res, ResMut};
use bevy_math::*; use bevy_math::*;
use std::{borrow::Cow, collections::HashSet}; use bevy_utils::HashSet;
use std::borrow::Cow;
use thiserror::Error; use thiserror::Error;
pub const VERTEX_BUFFER_ASSET_INDEX: usize = 0; pub const VERTEX_BUFFER_ASSET_INDEX: usize = 0;
@ -506,7 +507,7 @@ pub fn mesh_resource_provider_system(
vertex_buffer_descriptor vertex_buffer_descriptor
} }
}; };
let mut changed_meshes = HashSet::new(); let mut changed_meshes = HashSet::<Handle<Mesh>>::default();
let render_resource_context = &**render_resource_context; let render_resource_context = &**render_resource_context;
for event in state.mesh_event_reader.iter(&mesh_events) { for event in state.mesh_event_reader.iter(&mesh_events) {
match event { match event {

View File

@ -1,8 +1,6 @@
use super::BindingDescriptor; use super::BindingDescriptor;
use std::{ use bevy_utils::AHasher;
collections::hash_map::DefaultHasher, use std::hash::{Hash, Hasher};
hash::{Hash, Hasher},
};
#[derive(Clone, Debug, Eq)] #[derive(Clone, Debug, Eq)]
pub struct BindGroupDescriptor { pub struct BindGroupDescriptor {
@ -27,7 +25,7 @@ impl BindGroupDescriptor {
} }
pub fn update_id(&mut self) { pub fn update_id(&mut self) {
let mut hasher = DefaultHasher::new(); let mut hasher = AHasher::default();
self.hash(&mut hasher); self.hash(&mut hasher);
self.id = BindGroupDescriptorId(hasher.finish()); self.id = BindGroupDescriptorId(hasher.finish());
} }

View File

@ -5,9 +5,10 @@ use crate::{
}; };
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_property::{Properties, Property}; use bevy_property::{Properties, Property};
use bevy_utils::{HashMap, HashSet};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
#[derive(Clone, Eq, PartialEq, Debug, Properties)] #[derive(Clone, Eq, PartialEq, Debug, Properties)]
pub struct PipelineSpecialization { pub struct PipelineSpecialization {
pub shader_specialization: ShaderSpecialization, pub shader_specialization: ShaderSpecialization,

View File

@ -1,6 +1,7 @@
use super::{BindGroupDescriptor, VertexBufferDescriptor, VertexBufferDescriptors}; use super::{BindGroupDescriptor, VertexBufferDescriptor, VertexBufferDescriptors};
use crate::shader::{ShaderLayout, GL_VERTEX_INDEX}; use crate::shader::{ShaderLayout, GL_VERTEX_INDEX};
use std::{collections::HashMap, hash::Hash}; use bevy_utils::HashMap;
use std::hash::Hash;
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct PipelineLayout { pub struct PipelineLayout {
@ -16,7 +17,7 @@ impl PipelineLayout {
} }
pub fn from_shader_layouts(shader_layouts: &mut [ShaderLayout]) -> Self { pub fn from_shader_layouts(shader_layouts: &mut [ShaderLayout]) -> Self {
let mut bind_groups = HashMap::<u32, BindGroupDescriptor>::new(); let mut bind_groups = HashMap::<u32, BindGroupDescriptor>::default();
let mut vertex_buffer_descriptors = Vec::new(); let mut vertex_buffer_descriptors = Vec::new();
for shader_layout in shader_layouts.iter_mut() { for shader_layout in shader_layouts.iter_mut() {
for shader_bind_group in shader_layout.bind_groups.iter_mut() { for shader_bind_group in shader_layout.bind_groups.iter_mut() {

View File

@ -1,5 +1,6 @@
use super::VertexFormat; use super::VertexFormat;
use std::{borrow::Cow, collections::HashMap}; use bevy_utils::HashMap;
use std::borrow::Cow;
pub use bevy_derive::AsVertexBufferDescriptor; pub use bevy_derive::AsVertexBufferDescriptor;

View File

@ -1,7 +1,7 @@
use super::{Edge, Node, NodeId, NodeLabel, NodeState, RenderGraphError, SlotLabel, SystemNode}; use super::{Edge, Node, NodeId, NodeLabel, NodeState, RenderGraphError, SlotLabel, SystemNode};
use bevy_ecs::{Commands, Schedule}; use bevy_ecs::{Commands, Schedule};
use std::{borrow::Cow, collections::HashMap, fmt::Debug}; use bevy_utils::HashMap;
use std::{borrow::Cow, fmt::Debug};
pub struct RenderGraph { pub struct RenderGraph {
nodes: HashMap<NodeId, NodeState>, nodes: HashMap<NodeId, NodeState>,
node_names: HashMap<Cow<'static, str>, NodeId>, node_names: HashMap<Cow<'static, str>, NodeId>,
@ -300,7 +300,8 @@ mod tests {
renderer::{RenderContext, RenderResourceType}, renderer::{RenderContext, RenderResourceType},
}; };
use bevy_ecs::{Resources, World}; use bevy_ecs::{Resources, World};
use std::{collections::HashSet, iter::FromIterator}; use bevy_utils::HashSet;
use std::iter::FromIterator;
#[derive(Debug)] #[derive(Debug)]
struct TestNode { struct TestNode {

View File

@ -13,8 +13,9 @@ use bevy_asset::{Assets, Handle};
use bevy_ecs::{ use bevy_ecs::{
Commands, Entity, IntoQuerySystem, Local, Query, Res, ResMut, Resources, System, World, Commands, Entity, IntoQuerySystem, Local, Query, Res, ResMut, Resources, System, World,
}; };
use bevy_utils::HashMap;
use renderer::{AssetRenderResourceBindings, BufferId, RenderResourceType, RenderResources}; use renderer::{AssetRenderResourceBindings, BufferId, RenderResourceType, RenderResources};
use std::{collections::HashMap, hash::Hash, marker::PhantomData, ops::DerefMut}; use std::{hash::Hash, marker::PhantomData, ops::DerefMut};
pub const BIND_BUFFER_ALIGNMENT: usize = 256; pub const BIND_BUFFER_ALIGNMENT: usize = 256;
@ -55,7 +56,7 @@ impl<I: Hash + Eq> BufferArray<I> {
min_capacity, min_capacity,
buffer: None, buffer: None,
free_indices: Vec::new(), free_indices: Vec::new(),
indices: HashMap::new(), indices: HashMap::default(),
} }
} }

View File

@ -1,5 +1,5 @@
use super::{NodeId, NodeState, RenderGraph, RenderGraphError}; use super::{NodeId, NodeState, RenderGraph, RenderGraphError};
use std::collections::HashMap; use bevy_utils::HashMap;
use thiserror::Error; use thiserror::Error;
#[derive(Error, Debug)] #[derive(Error, Debug)]
@ -161,7 +161,7 @@ impl RenderGraphStager for DependentNodeStager {
.iter_nodes() .iter_nodes()
.filter(|node| node.input_slots.is_empty()); .filter(|node| node.input_slots.is_empty());
let mut stages = vec![Stage::default()]; let mut stages = vec![Stage::default()];
let mut node_stages = HashMap::new(); let mut node_stages = HashMap::default();
for output_only_node in output_only_nodes { for output_only_node in output_only_nodes {
// each "output only" node should start a new job on the first stage // each "output only" node should start a new job on the first stage
stage_node( stage_node(

View File

@ -6,9 +6,10 @@ use crate::{
texture::{SamplerDescriptor, TextureDescriptor}, texture::{SamplerDescriptor, TextureDescriptor},
}; };
use bevy_asset::{Assets, Handle, HandleUntyped}; use bevy_asset::{Assets, Handle, HandleUntyped};
use bevy_utils::HashMap;
use bevy_window::Window; use bevy_window::Window;
use parking_lot::RwLock; use parking_lot::RwLock;
use std::{collections::HashMap, ops::Range, sync::Arc}; use std::{ops::Range, sync::Arc};
#[derive(Default)] #[derive(Default)]
pub struct HeadlessRenderResourceContext { pub struct HeadlessRenderResourceContext {

View File

@ -1,6 +1,6 @@
use super::{BufferId, RenderResourceBinding, SamplerId, TextureId}; use super::{BufferId, RenderResourceBinding, SamplerId, TextureId};
use bevy_utils::AHasher;
use std::{ use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
ops::Range, ops::Range,
sync::Arc, sync::Arc,
@ -32,7 +32,7 @@ impl BindGroup {
pub struct BindGroupBuilder { pub struct BindGroupBuilder {
pub indexed_bindings: Vec<IndexedBindGroupEntry>, pub indexed_bindings: Vec<IndexedBindGroupEntry>,
pub dynamic_uniform_indices: Vec<u32>, pub dynamic_uniform_indices: Vec<u32>,
pub hasher: DefaultHasher, pub hasher: AHasher,
} }
impl BindGroupBuilder { impl BindGroupBuilder {

View File

@ -4,11 +4,8 @@ use crate::{
renderer::RenderResourceContext, renderer::RenderResourceContext,
}; };
use bevy_asset::{Handle, HandleUntyped}; use bevy_asset::{Handle, HandleUntyped};
use std::{ use bevy_utils::{HashMap, HashSet};
collections::{HashMap, HashSet}, use std::{hash::Hash, ops::Range};
hash::Hash,
ops::Range,
};
use uuid::Uuid; use uuid::Uuid;
#[derive(Clone, Eq, Debug)] #[derive(Clone, Eq, Debug)]

View File

@ -6,6 +6,7 @@ use crate::{
texture::{TextureComponentType, TextureViewDimension}, texture::{TextureComponentType, TextureViewDimension},
}; };
use bevy_core::AsBytes; use bevy_core::AsBytes;
use bevy_utils::HashSet;
use spirv_reflect::{ use spirv_reflect::{
types::{ types::{
ReflectDescriptorBinding, ReflectDescriptorSet, ReflectDescriptorType, ReflectDimension, ReflectDescriptorBinding, ReflectDescriptorSet, ReflectDescriptorType, ReflectDimension,
@ -14,7 +15,6 @@ use spirv_reflect::{
}, },
ShaderModule, ShaderModule,
}; };
use std::collections::HashSet;
/// Defines the memory layout of a shader /// Defines the memory layout of a shader
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
@ -51,7 +51,7 @@ impl ShaderLayout {
vertex_attribute_descriptors vertex_attribute_descriptors
.sort_by(|a, b| a.shader_location.cmp(&b.shader_location)); .sort_by(|a, b| a.shader_location.cmp(&b.shader_location));
let mut visited_buffer_descriptors = HashSet::new(); let mut visited_buffer_descriptors = HashSet::default();
let mut vertex_buffer_descriptors = Vec::new(); let mut vertex_buffer_descriptors = Vec::new();
let mut current_descriptor: Option<VertexBufferDescriptor> = None; let mut current_descriptor: Option<VertexBufferDescriptor> = None;
for vertex_attribute_descriptor in vertex_attribute_descriptors.drain(..) { for vertex_attribute_descriptor in vertex_attribute_descriptors.drain(..) {

View File

@ -6,7 +6,7 @@ use bevy_app::prelude::{EventReader, Events};
use bevy_asset::{AssetEvent, Assets, Handle}; use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_ecs::{Res, ResMut}; use bevy_ecs::{Res, ResMut};
use bevy_math::Vec2; use bevy_math::Vec2;
use std::collections::HashSet; use bevy_utils::HashSet;
pub const TEXTURE_ASSET_INDEX: usize = 0; pub const TEXTURE_ASSET_INDEX: usize = 0;
pub const SAMPLER_ASSET_INDEX: usize = 1; pub const SAMPLER_ASSET_INDEX: usize = 1;
@ -78,7 +78,7 @@ impl Texture {
texture_events: Res<Events<AssetEvent<Texture>>>, texture_events: Res<Events<AssetEvent<Texture>>>,
) { ) {
let render_resource_context = &**render_resource_context; let render_resource_context = &**render_resource_context;
let mut changed_textures = HashSet::new(); let mut changed_textures = HashSet::default();
for event in state.event_reader.iter(&texture_events) { for event in state.event_reader.iter(&texture_events) {
match event { match event {
AssetEvent::Created { handle } => { AssetEvent::Created { handle } => {

View File

@ -22,6 +22,7 @@ exclude = ["bors.toml", ".travis.yml"]
name = "bevy_ron" name = "bevy_ron"
[dependencies] [dependencies]
bevy_utils = { path = "../bevy_utils", version = "0.1" }
base64 = "0.12" base64 = "0.12"
bitflags = "1.0.4" bitflags = "1.0.4"
indexmap = { version = "1.0.2", features = ["serde-1"], optional = true } indexmap = { version = "1.0.2", features = ["serde-1"], optional = true }
@ -29,4 +30,4 @@ serde = { version = "1.0.60", features = ["serde_derive"] }
[dev-dependencies] [dev-dependencies]
serde_bytes = "0.11" serde_bytes = "0.11"
serde_json = "1" serde_json = "1"

View File

@ -83,9 +83,9 @@ fn test_array() {
#[test] #[test]
fn test_map() { fn test_map() {
use std::collections::HashMap; use bevy_utils::HashMap;
let mut map = HashMap::new(); let mut map = HashMap::default();
map.insert((true, false), 4); map.insert((true, false), 4);
map.insert((false, false), 123); map.insert((false, false), 123);
@ -159,7 +159,7 @@ fn err<T>(kind: ErrorCode, line: usize, col: usize) -> Result<T> {
#[test] #[test]
fn test_err_wrong_value() { fn test_err_wrong_value() {
use self::ErrorCode::*; use self::ErrorCode::*;
use std::collections::HashMap; use bevy_utils::HashMap;
assert_eq!(from_str::<f32>("'c'"), err(ExpectedFloat, 1, 1)); assert_eq!(from_str::<f32>("'c'"), err(ExpectedFloat, 1, 1));
assert_eq!(from_str::<String>("'c'"), err(ExpectedString, 1, 1)); assert_eq!(from_str::<String>("'c'"), err(ExpectedString, 1, 1));

View File

@ -958,9 +958,9 @@ mod tests {
#[test] #[test]
fn test_map() { fn test_map() {
use std::collections::HashMap; use bevy_utils::HashMap;
let mut map = HashMap::new(); let mut map = HashMap::default();
map.insert((true, false), 4); map.insert((true, false), 4);
map.insert((false, false), 123); map.insert((false, false), 123);

View File

@ -16,6 +16,7 @@ bevy_asset = { path = "../bevy_asset", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_property = { path = "../bevy_property", version = "0.1" } bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
serde = { version = "1.0", features = ["derive"]} serde = { version = "1.0", features = ["derive"]}

View File

@ -3,7 +3,7 @@ use bevy_app::prelude::*;
use bevy_asset::{AssetEvent, Assets, Handle}; use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_ecs::{Resources, World}; use bevy_ecs::{Resources, World};
use bevy_type_registry::TypeRegistry; use bevy_type_registry::TypeRegistry;
use std::collections::{HashMap, HashSet}; use bevy_utils::{HashMap, HashSet};
use thiserror::Error; use thiserror::Error;
use uuid::Uuid; use uuid::Uuid;

View File

@ -19,6 +19,7 @@ bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_render = { path = "../bevy_render", version = "0.1" } bevy_render = { path = "../bevy_render", version = "0.1" }
bevy_transform = { path = "../bevy_transform", version = "0.1" } bevy_transform = { path = "../bevy_transform", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
rectangle-pack = "0.1" rectangle-pack = "0.1"

View File

@ -7,7 +7,7 @@ use bevy_render::{
renderer::{RenderResource, RenderResources}, renderer::{RenderResource, RenderResources},
texture::Texture, texture::Texture,
}; };
use std::collections::HashMap; use bevy_utils::HashMap;
/// An atlas containing multiple textures (like a spritesheet or a tilemap) /// An atlas containing multiple textures (like a spritesheet or a tilemap)
#[derive(RenderResources)] #[derive(RenderResources)]

View File

@ -2,11 +2,11 @@ use crate::{Rect, TextureAtlas};
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::texture::{Texture, TextureFormat}; use bevy_render::texture::{Texture, TextureFormat};
use bevy_utils::HashMap;
use rectangle_pack::{ use rectangle_pack::{
contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation,
RectToInsert, TargetBin, RectToInsert, TargetBin,
}; };
use std::collections::HashMap;
use thiserror::Error; use thiserror::Error;
pub struct TextureAtlasBuilder { pub struct TextureAtlasBuilder {
@ -88,7 +88,7 @@ impl TextureAtlasBuilder {
rect_placements = None; rect_placements = None;
break; break;
} }
let mut target_bins = HashMap::new(); let mut target_bins = std::collections::HashMap::new();
target_bins.insert(0, TargetBin::new(current_width, current_height, 1)); target_bins.insert(0, TargetBin::new(current_width, current_height, 1));
atlas_texture = Texture::new_fill( atlas_texture = Texture::new_fill(
Vec2::new(current_width as f32, current_height as f32), Vec2::new(current_width as f32, current_height as f32),
@ -113,7 +113,7 @@ impl TextureAtlasBuilder {
let rect_placements = rect_placements.ok_or_else(|| RectanglePackError::NotEnoughSpace)?; let rect_placements = rect_placements.ok_or_else(|| RectanglePackError::NotEnoughSpace)?;
let mut texture_rects = Vec::with_capacity(rect_placements.packed_locations().len()); let mut texture_rects = Vec::with_capacity(rect_placements.packed_locations().len());
let mut texture_handles = HashMap::new(); let mut texture_handles = HashMap::default();
for (texture_handle, (_, packed_location)) in rect_placements.packed_locations().iter() { for (texture_handle, (_, packed_location)) in rect_placements.packed_locations().iter() {
let texture = textures.get(texture_handle).unwrap(); let texture = textures.get(texture_handle).unwrap();
let min = Vec2::new(packed_location.x() as f32, packed_location.y() as f32); let min = Vec2::new(packed_location.x() as f32, packed_location.y() as f32);

View File

@ -17,6 +17,7 @@ bevy_core = { path = "../bevy_core", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_render = { path = "../bevy_render", version = "0.1" } bevy_render = { path = "../bevy_render", version = "0.1" }
bevy_sprite = { path = "../bevy_sprite", version = "0.1" } bevy_sprite = { path = "../bevy_sprite", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
ab_glyph = "0.2.2" ab_glyph = "0.2.2"

View File

@ -2,7 +2,7 @@ use bevy_asset::{Assets, Handle};
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::texture::{Texture, TextureFormat}; use bevy_render::texture::{Texture, TextureFormat};
use bevy_sprite::{DynamicTextureAtlasBuilder, TextureAtlas}; use bevy_sprite::{DynamicTextureAtlasBuilder, TextureAtlas};
use std::collections::HashMap; use bevy_utils::HashMap;
pub struct FontAtlas { pub struct FontAtlas {
pub dynamic_texture_atlas_builder: DynamicTextureAtlasBuilder, pub dynamic_texture_atlas_builder: DynamicTextureAtlasBuilder,
@ -24,7 +24,7 @@ impl FontAtlas {
let texture_atlas = TextureAtlas::new_empty(atlas_texture, size); let texture_atlas = TextureAtlas::new_empty(atlas_texture, size);
Self { Self {
texture_atlas: texture_atlases.add(texture_atlas), texture_atlas: texture_atlases.add(texture_atlas),
glyph_to_index: HashMap::new(), glyph_to_index: HashMap::default(),
dynamic_texture_atlas_builder: DynamicTextureAtlasBuilder::new(size, 1), dynamic_texture_atlas_builder: DynamicTextureAtlasBuilder::new(size, 1),
} }
} }

View File

@ -5,7 +5,7 @@ use bevy_core::FloatOrd;
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::texture::Texture; use bevy_render::texture::Texture;
use bevy_sprite::TextureAtlas; use bevy_sprite::TextureAtlas;
use std::collections::HashMap; use bevy_utils::HashMap;
// work around rust's f32 order/hash limitations // work around rust's f32 order/hash limitations
type FontSizeKey = FloatOrd; type FontSizeKey = FloatOrd;
@ -26,7 +26,7 @@ impl FontAtlasSet {
pub fn new(font: Handle<Font>) -> Self { pub fn new(font: Handle<Font>) -> Self {
Self { Self {
font, font,
font_atlases: HashMap::new(), font_atlases: HashMap::default(),
} }
} }

View File

@ -16,8 +16,8 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_property = { path = "../bevy_property", version = "0.1" } bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
log = "0.4" log = "0.4"
smallvec = { version = "1.4", features = ["serde"] } smallvec = { version = "1.4", features = ["serde"] }

View File

@ -1,7 +1,7 @@
use crate::components::*; use crate::components::*;
use bevy_ecs::{Commands, Entity, IntoQuerySystem, Query, System, Without}; use bevy_ecs::{Commands, Entity, IntoQuerySystem, Query, System, Without};
use bevy_utils::HashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::HashMap;
pub fn missing_previous_parent_system( pub fn missing_previous_parent_system(
mut commands: Commands, mut commands: Commands,
@ -36,7 +36,7 @@ pub fn parent_update_system(
} }
// Tracks all newly created `Children` Components this frame. // Tracks all newly created `Children` Components this frame.
let mut children_additions = HashMap::<Entity, SmallVec<[Entity; 8]>>::new(); let mut children_additions = HashMap::<Entity, SmallVec<[Entity; 8]>>::default();
// Entities with a changed Parent (that also have a PreviousParent, even if None) // Entities with a changed Parent (that also have a PreviousParent, even if None)
for (entity, parent, mut previous_parent) in &mut changed_parent_query.iter() { for (entity, parent, mut previous_parent) in &mut changed_parent_query.iter() {

View File

@ -14,6 +14,7 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.1" } bevy_app = { path = "../bevy_app", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_property = { path = "../bevy_property", version = "0.1" } bevy_property = { path = "../bevy_property", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }

View File

@ -1,11 +1,8 @@
use bevy_ecs::{Archetype, Component, Entity, FromResources, Resources, World}; use bevy_ecs::{Archetype, Component, Entity, FromResources, Resources, World};
use bevy_property::{Properties, Property, PropertyTypeRegistration, PropertyTypeRegistry}; use bevy_property::{Properties, Property, PropertyTypeRegistration, PropertyTypeRegistry};
use bevy_utils::{HashMap, HashSet};
use parking_lot::RwLock; use parking_lot::RwLock;
use std::{ use std::{any::TypeId, sync::Arc};
any::TypeId,
collections::{HashMap, HashSet},
sync::Arc,
};
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct TypeRegistry { pub struct TypeRegistry {

View File

@ -24,6 +24,7 @@ bevy_text = { path = "../bevy_text", version = "0.1" }
bevy_transform = { path = "../bevy_transform", version = "0.1" } bevy_transform = { path = "../bevy_transform", version = "0.1" }
bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" } bevy_type_registry = { path = "../bevy_type_registry", version = "0.1" }
bevy_window = { path = "../bevy_window", version = "0.1" } bevy_window = { path = "../bevy_window", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
stretch = "0.3" stretch = "0.3"

View File

@ -4,8 +4,8 @@ use crate::{CalculatedSize, Node, Style};
use bevy_ecs::{Changed, Entity, Query, Res, ResMut, With, Without}; use bevy_ecs::{Changed, Entity, Query, Res, ResMut, With, Without};
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_transform::prelude::{Children, LocalTransform, Parent}; use bevy_transform::prelude::{Children, LocalTransform, Parent};
use bevy_utils::HashMap;
use bevy_window::{Window, WindowId, Windows}; use bevy_window::{Window, WindowId, Windows};
use std::collections::HashMap;
use stretch::{number::Number, Stretch}; use stretch::{number::Number, Stretch};
pub struct FlexSurface { pub struct FlexSurface {

View File

@ -0,0 +1,13 @@
[package]
name = "bevy_utils"
version = "0.1.3"
edition = "2018"
authors = ["Bevy Contributors <bevyengine@gmail.com>", "Carter Anderson <mcanders1@gmail.com>"]
description = "A collection of utils for Bevy Engine"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT"
keywords = ["bevy"]
[dependencies]
ahash = "0.4.4"

View File

@ -0,0 +1,15 @@
pub use ahash::AHasher;
use ahash::RandomState;
pub type HashMap<K, V> = std::collections::HashMap<K, V, RandomState>;
pub type HashSet<K> = std::collections::HashSet<K, RandomState>;
pub trait HashMapExt {
fn with_capacity(cap: usize) -> Self;
}
impl<K, V> HashMapExt for HashMap<K, V> {
fn with_capacity(cap: usize) -> Self {
HashMap::with_capacity_and_hasher(cap, RandomState::default())
}
}

View File

@ -23,6 +23,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_render = { path = "../bevy_render", version = "0.1" } bevy_render = { path = "../bevy_render", version = "0.1" }
bevy_window = { path = "../bevy_window", version = "0.1" } bevy_window = { path = "../bevy_window", version = "0.1" }
bevy_winit = { path = "../bevy_winit", optional = true, version = "0.1" } bevy_winit = { path = "../bevy_winit", optional = true, version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
wgpu = "0.6" wgpu = "0.6"

View File

@ -4,8 +4,9 @@ use bevy_render::{
render_graph::{Edge, NodeId, ResourceSlots, StageBorrow}, render_graph::{Edge, NodeId, ResourceSlots, StageBorrow},
renderer::RenderResourceContext, renderer::RenderResourceContext,
}; };
use bevy_utils::HashMap;
use parking_lot::RwLock; use parking_lot::RwLock;
use std::{collections::HashMap, sync::Arc}; use std::sync::Arc;
pub struct WgpuRenderGraphExecutor { pub struct WgpuRenderGraphExecutor {
pub max_thread_count: usize, pub max_thread_count: usize,

View File

@ -5,9 +5,10 @@ use bevy_render::{
shader::Shader, shader::Shader,
texture::TextureDescriptor, texture::TextureDescriptor,
}; };
use bevy_utils::HashMap;
use bevy_window::WindowId; use bevy_window::WindowId;
use parking_lot::{RwLock, RwLockReadGuard}; use parking_lot::{RwLock, RwLockReadGuard};
use std::{collections::HashMap, sync::Arc}; use std::sync::Arc;
#[derive(Default)] #[derive(Default)]
pub struct WgpuBindGroupInfo { pub struct WgpuBindGroupInfo {

View File

@ -14,6 +14,7 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.1" } bevy_app = { path = "../bevy_app", version = "0.1" }
bevy_ecs = { path = "../bevy_ecs", version = "0.1" } bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
uuid = { version = "0.8", features = ["v4", "serde"] } uuid = { version = "0.8", features = ["v4", "serde"] }

View File

@ -1,5 +1,5 @@
use super::{Window, WindowId}; use super::{Window, WindowId};
use std::collections::HashMap; use bevy_utils::HashMap;
#[derive(Default)] #[derive(Default)]
pub struct Windows { pub struct Windows {

View File

@ -20,6 +20,7 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.1" }
bevy_input = { path = "../bevy_input", version = "0.1" } bevy_input = { path = "../bevy_input", version = "0.1" }
bevy_math = { path = "../bevy_math", version = "0.1" } bevy_math = { path = "../bevy_math", version = "0.1" }
bevy_window = { path = "../bevy_window", version = "0.1" } bevy_window = { path = "../bevy_window", version = "0.1" }
bevy_utils = { path = "../bevy_utils", version = "0.1" }
# other # other
winit = { version = "0.22.2", package = "cart-tmp-winit", default-features = false} winit = { version = "0.22.2", package = "cart-tmp-winit", default-features = false}

View File

@ -1,5 +1,5 @@
use bevy_utils::HashMap;
use bevy_window::{Window, WindowId, WindowMode}; use bevy_window::{Window, WindowId, WindowMode};
use std::collections::HashMap;
#[derive(Default)] #[derive(Default)]
pub struct WinitWindows { pub struct WinitWindows {