Switch to fxhash from ahash
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sijmen 2021-06-11 17:39:59 +02:00
parent 0e96293fe8
commit 8ecb9ea813
Signed by: vijfhoek
GPG key ID: 82D05C89B28B0DAE
4 changed files with 20 additions and 48 deletions

38
Cargo.lock generated
View file

@ -24,17 +24,6 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
[[package]]
name = "ahash"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98"
dependencies = [
"getrandom 0.2.3",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.18"
@ -692,18 +681,7 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi",
]
[[package]]
@ -962,7 +940,7 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [
"ahash 0.4.7",
"ahash",
]
[[package]]
@ -1210,12 +1188,12 @@ dependencies = [
name = "minecrab"
version = "0.1.0"
dependencies = [
"ahash 0.7.4",
"anyhow",
"bytemuck",
"cgmath",
"env_logger",
"futures",
"fxhash",
"gltf",
"image",
"itertools 0.10.0",
@ -1634,7 +1612,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.16",
"getrandom",
"libc",
"rand_chacha",
"rand_core",
@ -1657,7 +1635,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom 0.1.16",
"getrandom",
]
[[package]]
@ -2047,12 +2025,6 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.74"

View file

@ -6,24 +6,24 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
gltf = "0.16"
ahash = "0.7.4"
anyhow = "1.0.40"
bytemuck = { version = "1.5.1", features = ["derive"] }
cgmath = "0.18.0"
env_logger = "0.8.3"
futures = "0.3.15"
fxhash = "0.2.1"
gltf = "0.16"
image = "0.23.14"
itertools = "0.10.0"
log = "0.4.14"
noise = "0.7.0"
rayon = "1.5.1"
rmp-serde = "0.15.4"
serde = { version = "1.0.126", features = ["derive"] }
serde_repr = "0.1.7"
sled = { version = "0.34.6", features = ["compression"] }
wgpu = "0.8.1"
winit = { version = "0.25.0" }
serde_repr = "0.1.7"
rmp-serde = "0.15.4"
itertools = "0.10.0"
serde = { version = "1.0.126", features = ["derive"] }
sled = { version = "0.34.6", features = ["compression"] }
[profile.release]
debug = true

View file

@ -13,8 +13,8 @@ use crate::{
quad::Quad,
},
};
use ahash::{AHashMap, AHashSet};
use cgmath::{Point3, Vector3};
use fxhash::{FxHashMap, FxHashSet};
use noise::utils::{NoiseMapBuilder, PlaneMapBuilder};
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use serde::{
@ -268,10 +268,10 @@ impl Chunk {
&self,
y: usize,
) -> (
AHashMap<(usize, usize), (BlockType, FaceFlags)>,
FxHashMap<(usize, usize), (BlockType, FaceFlags)>,
VecDeque<(usize, usize)>,
) {
let mut culled = AHashMap::new();
let mut culled = FxHashMap::default();
let mut queue = VecDeque::new();
let y_blocks = &self.blocks[y];
@ -297,12 +297,12 @@ impl Chunk {
&self,
y: usize,
offset: Point3<isize>,
culled: AHashMap<(usize, usize), (BlockType, FaceFlags)>,
culled: FxHashMap<(usize, usize), (BlockType, FaceFlags)>,
queue: &mut VecDeque<(usize, usize)>,
highlighted: Option<(Vector3<usize>, Vector3<i32>)>,
) -> Vec<Quad> {
let mut quads: Vec<Quad> = Vec::new();
let mut visited = AHashSet::new();
let mut visited = FxHashSet::default();
let hl = highlighted.map(|h| h.0);
while let Some((x, z)) = queue.pop_front() {
let position = offset + Vector3::new(x, y, z).cast().unwrap();

View file

@ -22,8 +22,8 @@ use crate::{
npc::Npc,
},
};
use ahash::AHashMap;
use cgmath::{EuclideanSpace, InnerSpace, Point3, Vector3};
use fxhash::FxHashMap;
use wgpu::{
util::{BufferInitDescriptor, DeviceExt},
BindGroup, Buffer, CommandEncoder, RenderPipeline, SwapChainTexture,
@ -39,7 +39,7 @@ pub struct World {
pub npc: Npc,
pub chunks: AHashMap<Point3<isize>, Chunk>,
pub chunks: FxHashMap<Point3<isize>, Chunk>,
pub chunk_database: sled::Db,
pub chunk_save_queue: VecDeque<(Point3<isize>, bool)>,
pub chunk_load_queue: VecDeque<Point3<isize>>,
@ -226,7 +226,7 @@ impl World {
}
pub fn new(render_context: &RenderContext, view: &View) -> Self {
let chunks = AHashMap::new();
let chunks = FxHashMap::default();
let mut npc = Npc::new();
npc.load_geometry(render_context);