diff --git a/Cargo.lock b/Cargo.lock index bc77bcf9f1..068ce3a238 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1279,6 +1279,14 @@ dependencies = [ "svg_fmt 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "heaptrack" version = "0.3.0" @@ -2891,6 +2899,7 @@ dependencies = [ name = "veloren-client" version = "0.3.0" dependencies = [ + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "specs 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2906,7 +2915,7 @@ dependencies = [ "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "dot_vox 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "find_folder 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2929,6 +2938,7 @@ name = "veloren-server" version = "0.3.0" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2967,15 +2977,14 @@ dependencies = [ "dot_vox 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "euc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "frustum_query 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_device_gl 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_window_glutin 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)", "glsl-include 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "guillotiere 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "heaptrack 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3001,7 +3010,7 @@ dependencies = [ name = "veloren-world" version = "0.3.0" dependencies = [ - "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "minifb 0.12.0 (git+https://github.com/emoon/rust_minifb.git)", "noise 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3331,6 +3340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gtk 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d695d6be4110618a97c19cd068e8a00e53e33b87e3c65cdc5397667498b1bc24" "checksum gtk-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d9554cf5b3a85a13fb39258c65b04b262989c1d7a758f8f555b77a478621a91" "checksum guillotiere 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "182af928b4435d8fbef910535586ecdca95ab4068493769c090e6573477f5e35" +"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum heaptrack 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a5f3c2341045ae29cc6d1004caf4c043addd7b658f9d11464fd6914dff6609b" "checksum hibitset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6527bc88f32e0d3926c7572874b2bf17a19b36978aacd0aacf75f7d27a5992d0" "checksum hound 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" diff --git a/client/Cargo.toml b/client/Cargo.toml index 8ea392a195..1a105b8e4f 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,3 +12,4 @@ num_cpus = "1.10.1" log = "0.4.8" specs = "0.14.2" vek = "0.9.8" +hashbrown = { version = "0.5.0", features = ["serde", "nightly"] } diff --git a/client/src/lib.rs b/client/src/lib.rs index 80921ec42f..37d70a6011 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -15,9 +15,9 @@ use common::{ vol::VolSize, ChatType, }; +use hashbrown::HashMap; use log::{info, log_enabled, warn}; use std::{ - collections::HashMap, net::SocketAddr, sync::Arc, time::{Duration, Instant}, diff --git a/common/Cargo.toml b/common/Cargo.toml index 77a64965b6..ed0edf6958 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -23,5 +23,5 @@ rand = "0.7.0" rayon = "1.1.0" lazy_static = "1.3.0" lz4-compress = "0.1.1" -fxhash = "0.2.1" +hashbrown = { version = "0.5.0", features = ["serde", "nightly"] } find_folder = "0.3.0" diff --git a/common/src/assets/mod.rs b/common/src/assets/mod.rs index 29af8eb333..c149a89df8 100644 --- a/common/src/assets/mod.rs +++ b/common/src/assets/mod.rs @@ -1,12 +1,12 @@ //! Load assets (images or voxel data) from files use dot_vox::DotVoxData; +use hashbrown::HashMap; use image::DynamicImage; use lazy_static::lazy_static; use serde_json::Value; use std::{ any::Any, - collections::HashMap, env, fs::{self, read_link, File, ReadDir}, io::{BufReader, Read}, diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 8e92e0d2be..6dbf86234c 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -4,7 +4,7 @@ use crate::{ terrain::{Block, TerrainChunk}, ChatType, }; -use fxhash::FxHashMap; +use hashbrown::HashMap; use vek::*; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -60,7 +60,7 @@ pub enum ServerMsg { key: Vec2, chunk: Box, }, - TerrainBlockUpdates(FxHashMap, Block>), + TerrainBlockUpdates(HashMap, Block>), Error(ServerError), Disconnect, Shutdown, diff --git a/common/src/state.rs b/common/src/state.rs index 2a19a74da9..7c38442b2f 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -9,7 +9,7 @@ use crate::{ terrain::{Block, TerrainChunk, TerrainMap}, vol::WriteVol, }; -use fxhash::{FxHashMap, FxHashSet}; +use hashbrown::{HashMap, HashSet}; use rayon::{ThreadPool, ThreadPoolBuilder}; use serde_derive::{Deserialize, Serialize}; use specs::{ @@ -45,7 +45,7 @@ const MAX_DELTA_TIME: f32 = 1.0; #[derive(Default)] pub struct BlockChange { - blocks: FxHashMap, Block>, + blocks: HashMap, Block>, } impl BlockChange { @@ -60,10 +60,10 @@ impl BlockChange { #[derive(Default)] pub struct TerrainChanges { - pub new_chunks: FxHashSet>, - pub modified_chunks: FxHashSet>, - pub removed_chunks: FxHashSet>, - pub modified_blocks: FxHashMap, Block>, + pub new_chunks: HashSet>, + pub modified_chunks: HashSet>, + pub removed_chunks: HashSet>, + pub modified_blocks: HashMap, Block>, } impl TerrainChanges { diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index a00f44a1f9..42541166e2 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -3,7 +3,7 @@ use crate::{ vol::{BaseVol, ReadVol, VolSize, WriteVol}, volumes::chunk::{Chunk, ChunkErr}, }; -use fxhash::FxHashMap; +use hashbrown::HashMap; use serde_derive::{Deserialize, Serialize}; use std::ops::Add; use vek::*; @@ -179,7 +179,7 @@ impl WriteVol for Chonk { // Can't fail SubChunk::Homogeneous(cblock) if block == *cblock => Ok(()), SubChunk::Homogeneous(cblock) => { - let mut map = FxHashMap::default(); + let mut map = HashMap::default(); map.insert(rpos.map(|e| e as u8), block); self.sub_chunks[sub_chunk_idx] = SubChunk::Hash(*cblock, map); @@ -238,7 +238,7 @@ impl VolSize for SubChunkSize { #[derive(Debug, Clone, Serialize, Deserialize)] pub enum SubChunk { Homogeneous(Block), - Hash(Block, FxHashMap, Block>), + Hash(Block, HashMap, Block>), Heterogeneous(Chunk), } diff --git a/common/src/volumes/vol_map_2d.rs b/common/src/volumes/vol_map_2d.rs index 28b29fdcbb..b3ba4d3d9d 100644 --- a/common/src/volumes/vol_map_2d.rs +++ b/common/src/volumes/vol_map_2d.rs @@ -2,8 +2,8 @@ use crate::{ vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol}, volumes::dyna::DynaErr, }; -use fxhash::FxHashMap; -use std::{collections::hash_map, fmt::Debug, marker::PhantomData, sync::Arc}; +use hashbrown::{hash_map, HashMap}; +use std::{fmt::Debug, marker::PhantomData, sync::Arc}; use vek::*; #[derive(Debug, Clone)] @@ -19,7 +19,7 @@ pub enum VolMap2dErr { // M = Chunk metadata #[derive(Clone)] pub struct VolMap2d { - chunks: FxHashMap, Arc>, + chunks: HashMap, Arc>, phantom: PhantomData, } @@ -122,7 +122,7 @@ impl VolMap2d { .reduce_and() { Ok(Self { - chunks: FxHashMap::default(), + chunks: HashMap::default(), phantom: PhantomData, }) } else { @@ -177,7 +177,7 @@ impl VolMap2d { } pub struct ChunkIter<'a, V: BaseVol> { - iter: std::collections::hash_map::Iter<'a, Vec2, Arc>, + iter: hash_map::Iter<'a, Vec2, Arc>, } impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> { diff --git a/common/src/volumes/vol_map_3d.rs b/common/src/volumes/vol_map_3d.rs index ad3bc42b9c..b1105d8cb7 100644 --- a/common/src/volumes/vol_map_3d.rs +++ b/common/src/volumes/vol_map_3d.rs @@ -2,7 +2,8 @@ use crate::{ vol::{BaseVol, ReadVol, SampleVol, VolSize, WriteVol}, volumes::dyna::DynaErr, }; -use std::{collections::HashMap, fmt::Debug, marker::PhantomData, sync::Arc}; +use hashbrown::{hash_map, HashMap}; +use std::{fmt::Debug, marker::PhantomData, sync::Arc}; use vek::*; #[derive(Debug)] @@ -161,7 +162,7 @@ impl VolMap3d { } pub struct ChunkIter<'a, V: BaseVol> { - iter: std::collections::hash_map::Iter<'a, Vec3, Arc>, + iter: hash_map::Iter<'a, Vec3, Arc>, } impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> { diff --git a/server/Cargo.toml b/server/Cargo.toml index 9b9812dcf9..c9dbb40257 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -19,3 +19,4 @@ serde = "1.0.98" serde_derive = "1.0.98" rand = "0.7.0" chrono = "0.4.7" +hashbrown = { version = "0.5.0", features = ["serde", "nightly"] } diff --git a/server/src/auth_provider.rs b/server/src/auth_provider.rs index 46a49d9503..68160a48e0 100644 --- a/server/src/auth_provider.rs +++ b/server/src/auth_provider.rs @@ -1,5 +1,5 @@ +use hashbrown::HashMap; use log::{info, warn}; -use std::collections::HashMap; pub struct AuthProvider { accounts: HashMap, diff --git a/server/src/client.rs b/server/src/client.rs index fb43465ebb..e174ff411f 100644 --- a/server/src/client.rs +++ b/server/src/client.rs @@ -2,8 +2,8 @@ use common::{ msg::{ClientMsg, ClientState, RequestStateError, ServerMsg}, net::PostBox, }; +use hashbrown::HashMap; use specs::Entity as EcsEntity; -use std::collections::HashMap; pub struct Client { pub client_state: ClientState, diff --git a/server/src/lib.rs b/server/src/lib.rs index f5006897c3..b1ab1ca702 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -25,11 +25,11 @@ use common::{ vol::Vox, vol::{ReadVol, VolSize}, }; +use hashbrown::HashSet; use log::debug; use rand::Rng; use specs::{join::Join, world::EntityBuilder as EcsEntityBuilder, Builder, Entity as EcsEntity}; use std::{ - collections::HashSet, i32, net::SocketAddr, sync::{mpsc, Arc}, diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index e18b498831..bf52ab9d35 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -46,7 +46,6 @@ serde = "1.0.98" serde_derive = "1.0.98" ron = "0.5.1" guillotiere = "0.4.2" -fnv = "1.0.6" simplelog = "0.6.0" msgbox = { git = "https://github.com/bekker/msgbox-rs.git" } directories = "2.0.2" @@ -57,5 +56,5 @@ rand = "0.7.0" frustum_query = "0.1.2" rodio = { git = "https://github.com/desttinghim/rodio.git", rev = "dd93f905c1afefaac03c496a666ecab27d3e391b" } crossbeam = "0.7.2" -fxhash = "0.2.1" heaptrack = "0.3.0" +hashbrown = { version = "0.5.0", features = ["serde", "nightly"] } diff --git a/voxygen/src/scene/figure.rs b/voxygen/src/scene/figure.rs index 1ca388ddc0..80bcdf5b09 100644 --- a/voxygen/src/scene/figure.rs +++ b/voxygen/src/scene/figure.rs @@ -18,9 +18,10 @@ use common::{ vol::VolSize, }; use dot_vox::DotVoxData; +use hashbrown::HashMap; use log::warn; use specs::{Entity as EcsEntity, Join}; -use std::{collections::HashMap, f32}; +use std::f32; use vek::*; const DAMAGE_FADE_COEFFICIENT: f64 = 5.0; diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index f1e70c4541..848c02d859 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -9,7 +9,7 @@ use common::{ volumes::vol_map_2d::VolMap2dErr, }; use frustum_query::frustum::Frustum; -use fxhash::FxHashMap; +use hashbrown::HashMap; use std::{i32, ops::Mul, sync::mpsc, time::Duration}; use vek::*; @@ -52,13 +52,13 @@ fn mesh_worker( } pub struct Terrain { - chunks: FxHashMap, TerrainChunk>, + chunks: HashMap, TerrainChunk>, // The mpsc sender and receiver used for talking to meshing worker threads. // We keep the sender component for no reason other than to clone it and send it to new workers. mesh_send_tmp: mpsc::Sender, mesh_recv: mpsc::Receiver, - mesh_todo: FxHashMap, ChunkMeshState>, + mesh_todo: HashMap, ChunkMeshState>, } impl Terrain { @@ -68,10 +68,10 @@ impl Terrain { let (send, recv) = mpsc::channel(); Self { - chunks: FxHashMap::default(), + chunks: HashMap::default(), mesh_send_tmp: send, mesh_recv: recv, - mesh_todo: FxHashMap::default(), + mesh_todo: HashMap::default(), } } diff --git a/voxygen/src/ui/graphic/graphic.rs b/voxygen/src/ui/graphic/graphic.rs index 97688ec662..c830be20b3 100644 --- a/voxygen/src/ui/graphic/graphic.rs +++ b/voxygen/src/ui/graphic/graphic.rs @@ -1,6 +1,6 @@ use dot_vox::DotVoxData; -use fnv::FnvHashMap; use guillotiere::{size2, AllocId, Allocation, AtlasAllocator}; +use hashbrown::HashMap; use image::{DynamicImage, RgbaImage}; use log::{error, warn}; use std::sync::Arc; @@ -28,28 +28,28 @@ pub struct CachedDetails { } pub struct GraphicCache { - graphic_map: FnvHashMap, + graphic_map: HashMap, next_id: u32, atlas: AtlasAllocator, - cache_map: FnvHashMap, + cache_map: HashMap, // The current frame current_frame: u32, unused_entries_this_frame: Option>>, - soft_cache: FnvHashMap, + soft_cache: HashMap, transfer_ready: Vec<(Parameters, Aabr)>, } impl GraphicCache { pub fn new(size: Vec2) -> Self { Self { - graphic_map: FnvHashMap::default(), + graphic_map: HashMap::default(), next_id: 0, atlas: AtlasAllocator::new(size2(i32::from(size.x), i32::from(size.y))), - cache_map: FnvHashMap::default(), + cache_map: HashMap::default(), current_frame: 0, unused_entries_this_frame: None, - soft_cache: FnvHashMap::default(), + soft_cache: HashMap::default(), transfer_ready: Vec::new(), } } diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index 5183ae6ba3..4ebd0e2088 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -3,9 +3,9 @@ use crate::{ settings::Settings, ui, Error, }; +use hashbrown::HashMap; use log::{error, warn}; use serde_derive::{Deserialize, Serialize}; -use std::collections::HashMap; use vek::*; /// Represents a key that the game recognises after keyboard mapping. diff --git a/world/Cargo.toml b/world/Cargo.toml index f31d0f1e43..4b86cfb732 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" common = { package = "veloren-common", path = "../common" } vek = "0.9.8" noise = "0.5.1" -fxhash = "0.2.1" +hashbrown = { version = "0.5.0", features = ["serde", "nightly"] } lazy_static = "1.3.0" rand = "0.7.0" rand_chacha = "0.2.1" diff --git a/world/src/sim/location.rs b/world/src/sim/location.rs index 93ac61b62c..2e548ef429 100644 --- a/world/src/sim/location.rs +++ b/world/src/sim/location.rs @@ -1,5 +1,5 @@ use super::Settlement; -use fxhash::FxHashSet; +use hashbrown::HashSet; use rand::seq::SliceRandom; use rand::Rng; use vek::*; @@ -9,7 +9,7 @@ pub struct Location { pub(crate) name: String, pub(crate) center: Vec2, pub(crate) kingdom: Option, - pub(crate) neighbours: FxHashSet, + pub(crate) neighbours: HashSet, pub(crate) settlement: Settlement, } @@ -19,7 +19,7 @@ impl Location { name: generate_name(rng), center, kingdom: None, - neighbours: FxHashSet::default(), + neighbours: HashSet::default(), settlement: Settlement::generate(rng), } } diff --git a/world/src/util/hash_cache.rs b/world/src/util/hash_cache.rs index a797d6c146..2abe5c8cd7 100644 --- a/world/src/util/hash_cache.rs +++ b/world/src/util/hash_cache.rs @@ -1,9 +1,9 @@ -use fxhash::FxHashMap; +use hashbrown::HashMap; use std::hash::Hash; pub struct HashCache { capacity: usize, - map: FxHashMap, + map: HashMap, counter: usize, } @@ -17,7 +17,7 @@ impl HashCache { pub fn with_capacity(capacity: usize) -> Self { Self { capacity, - map: FxHashMap::default(), + map: HashMap::default(), counter: 0, } }