Finished switch to hashbrown.

This commit is contained in:
Acrimon 2019-08-11 22:38:28 +02:00
parent ed4909670d
commit b4a46f3e6e
12 changed files with 29 additions and 25 deletions

5
Cargo.lock generated
View File

@ -1283,6 +1283,9 @@ dependencies = [
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"
@ -2912,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)",

View File

@ -12,4 +12,4 @@ num_cpus = "1.10.1"
log = "0.4.8"
specs = "0.14.2"
vek = "0.9.8"
hashbrown = "0.5.0"
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }

View File

@ -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"

View File

@ -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},

View File

@ -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<i32>,
chunk: Box<TerrainChunk>,
},
TerrainBlockUpdates(FxHashMap<Vec3<i32>, Block>),
TerrainBlockUpdates(HashMap<Vec3<i32>, Block>),
Error(ServerError),
Disconnect,
Shutdown,

View File

@ -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<Vec3<i32>, Block>,
blocks: HashMap<Vec3<i32>, Block>,
}
impl BlockChange {
@ -60,10 +60,10 @@ impl BlockChange {
#[derive(Default)]
pub struct TerrainChanges {
pub new_chunks: FxHashSet<Vec2<i32>>,
pub modified_chunks: FxHashSet<Vec2<i32>>,
pub removed_chunks: FxHashSet<Vec2<i32>>,
pub modified_blocks: FxHashMap<Vec3<i32>, Block>,
pub new_chunks: HashSet<Vec2<i32>>,
pub modified_chunks: HashSet<Vec2<i32>>,
pub removed_chunks: HashSet<Vec2<i32>>,
pub modified_blocks: HashMap<Vec3<i32>, Block>,
}
impl TerrainChanges {

View File

@ -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<Vec3<u8>, Block>),
Hash(Block, HashMap<Vec3<u8>, Block>),
Heterogeneous(Chunk<Block, SubChunkSize, ()>),
}

View File

@ -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<V: BaseVol> {
// M = Chunk metadata
#[derive(Clone)]
pub struct VolMap2d<V: BaseVol, S: VolSize> {
chunks: FxHashMap<Vec2<i32>, Arc<V>>,
chunks: HashMap<Vec2<i32>, Arc<V>>,
phantom: PhantomData<S>,
}
@ -122,7 +122,7 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
.reduce_and()
{
Ok(Self {
chunks: FxHashMap::default(),
chunks: HashMap::default(),
phantom: PhantomData,
})
} else {
@ -177,7 +177,7 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
}
pub struct ChunkIter<'a, V: BaseVol> {
iter: std::collections::hash_map::Iter<'a, Vec2<i32>, Arc<V>>,
iter: hash_map::Iter<'a, Vec2<i32>, Arc<V>>,
}
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {

View File

@ -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<V: BaseVol, S: VolSize> VolMap3d<V, S> {
}
pub struct ChunkIter<'a, V: BaseVol> {
iter: std::collections::hash_map::Iter<'a, Vec3<i32>, Arc<V>>,
iter: hash_map::Iter<'a, Vec3<i32>, Arc<V>>,
}
impl<'a, V: BaseVol> Iterator for ChunkIter<'a, V> {

View File

@ -19,4 +19,4 @@ serde = "1.0.98"
serde_derive = "1.0.98"
rand = "0.7.0"
chrono = "0.4.7"
hashbrown = "0.5.0"
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }

View File

@ -57,4 +57,4 @@ frustum_query = "0.1.2"
rodio = { git = "https://github.com/desttinghim/rodio.git", rev = "dd93f905c1afefaac03c496a666ecab27d3e391b" }
crossbeam = "0.7.2"
heaptrack = "0.3.0"
hashbrown = "0.5.0"
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }

View File

@ -8,7 +8,7 @@ edition = "2018"
common = { package = "veloren-common", path = "../common" }
vek = "0.9.8"
noise = "0.5.1"
hashbrown = "0.5.0"
hashbrown = { version = "0.5.0", features = ["serde", "nightly"] }
lazy_static = "1.3.0"
rand = "0.7.0"
rand_chacha = "0.2.1"