From e819cd2309ca879edc835c7a0b8d6b522eebdfb4 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 16 Apr 2023 19:39:02 -0400 Subject: [PATCH] Updated hashbrown, removed some to_owned calls in handling recently unequipped items --- Cargo.lock | 33 +++++++++++++++++---------- client/Cargo.toml | 2 +- client/i18n/Cargo.toml | 2 +- common/Cargo.toml | 2 +- common/net/Cargo.toml | 2 +- common/src/comp/inventory/item/mod.rs | 5 ++++ common/src/comp/inventory/loadout.rs | 5 ++-- common/src/comp/inventory/mod.rs | 2 +- common/state/Cargo.toml | 2 +- common/systems/Cargo.toml | 2 +- network/Cargo.toml | 2 +- network/protocol/Cargo.toml | 2 +- rtsim/Cargo.toml | 2 +- server/Cargo.toml | 2 +- voxygen/Cargo.toml | 2 +- voxygen/src/hud/group.rs | 2 +- world/Cargo.toml | 2 +- 17 files changed, 42 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df37680f44..7275021bc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2685,6 +2685,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.0", "rayon", "serde", ] @@ -6651,7 +6660,7 @@ dependencies = [ "authc", "byteorder", "clap 3.2.22", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "image", "num 0.4.0", "quinn", @@ -6686,7 +6695,7 @@ dependencies = [ "fluent", "fluent-bundle", "fluent-syntax", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "intl-memoizer", "ron 0.8.0", "serde", @@ -6713,7 +6722,7 @@ dependencies = [ "dot_vox", "enum-map", "fxhash", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "indexmap", "itertools", "kiddo 0.1.7", @@ -6808,7 +6817,7 @@ version = "0.10.0" dependencies = [ "bincode", "flate2", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "image", "num-traits", "serde", @@ -6824,7 +6833,7 @@ name = "veloren-common-state" version = "0.10.0" dependencies = [ "bincode", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "num_cpus", "rayon", "scopeguard", @@ -6847,7 +6856,7 @@ dependencies = [ name = "veloren-common-systems" version = "0.10.0" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.13.2", "indexmap", "itertools", "ordered-float 3.1.0", @@ -6878,7 +6887,7 @@ dependencies = [ "crossbeam-channel", "futures-core", "futures-util", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "lazy_static", "lz-fear", "prometheus", @@ -6906,7 +6915,7 @@ dependencies = [ "bitflags", "bytes", "criterion", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "prometheus", "rand 0.8.5", "tokio", @@ -6949,7 +6958,7 @@ dependencies = [ "atomic_refcell", "enum-map", "fxhash", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "itertools", "rand 0.8.5", "rand_chacha 0.3.1", @@ -6979,7 +6988,7 @@ dependencies = [ "enum-map", "enumset", "futures-util", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "humantime", "itertools", "lazy_static", @@ -7095,7 +7104,7 @@ dependencies = [ "gilrs", "glyph_brush", "guillotiere", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "iced_native", "iced_winit", "image", @@ -7195,7 +7204,7 @@ dependencies = [ "fallible-iterator", "flate2", "fxhash", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "image", "inline_tweak", "itertools", diff --git a/client/Cargo.toml b/client/Cargo.toml index 7a7cbb992c..2c06f7c623 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -30,7 +30,7 @@ tracing = { version = "0.1", default-features = false } rayon = "1.5" specs = { version = "0.18", features = ["serde", "storage-event-control", "derive"] } vek = { version = "0.15.8", features = ["serde"] } -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "fb3dcbc4962b367253f8f2f92760ef44d2679c9a" } #TODO: put bot in a different crate diff --git a/client/i18n/Cargo.toml b/client/i18n/Cargo.toml index 593fcd7adb..1c074c0cb4 100644 --- a/client/i18n/Cargo.toml +++ b/client/i18n/Cargo.toml @@ -17,7 +17,7 @@ intl-memoizer = { git = "https://github.com/juliancoffee/fluent-rs.git", branch fluent = { git = "https://github.com/juliancoffee/fluent-rs.git", branch = "patched"} fluent-bundle = { git = "https://github.com/juliancoffee/fluent-rs.git", branch = "patched"} # Utility -hashbrown = { version = "0.12", features = ["serde", "nightly"] } +hashbrown = { version = "0.13", features = ["serde", "nightly"] } deunicode = "1.0" tracing = "0.1" # Bin diff --git a/common/Cargo.toml b/common/Cargo.toml index 8aff837d6b..e3ddc7d43b 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -74,7 +74,7 @@ petgraph = { version = "0.6", optional = true } kiddo = { version = "0.1", optional = true } # Data structures -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } slotmap = { version = "1.0", features = ["serde"] } indexmap = { version = "1.3.0", features = ["rayon"] } slab = "0.4.2" diff --git a/common/net/Cargo.toml b/common/net/Cargo.toml index 4b23bf1eaa..0d9f9a28e4 100644 --- a/common/net/Cargo.toml +++ b/common/net/Cargo.toml @@ -22,7 +22,7 @@ vek = { version = "0.15.8", features = ["serde"] } tracing = { version = "0.1", default-features = false } # Data structures -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } # ECS specs = { version = "0.18", features = ["serde", "storage-event-control"] } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index a003c50ee7..e3299a46ac 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -20,6 +20,7 @@ use core::{ num::{NonZeroU32, NonZeroU64}, }; use crossbeam_utils::atomic::AtomicCell; +use hashbrown::Equivalent; use serde::{de, Deserialize, Serialize, Serializer}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage}; use std::{borrow::Cow, collections::hash_map::DefaultHasher, fmt, sync::Arc}; @@ -1451,6 +1452,10 @@ impl PartialEq for ItemDefinitionId<'_> { fn eq(&self, other: &ItemDefinitionIdOwned) -> bool { other == self } } +impl Equivalent for ItemDefinitionId<'_> { + fn equivalent(&self, key: &ItemDefinitionIdOwned) -> bool { self == key } +} + #[cfg(test)] mod tests { use super::*; diff --git a/common/src/comp/inventory/loadout.rs b/common/src/comp/inventory/loadout.rs index 4a6b237bee..a3770b9730 100644 --- a/common/src/comp/inventory/loadout.rs +++ b/common/src/comp/inventory/loadout.rs @@ -107,9 +107,8 @@ impl Loadout { time: Time, ) -> Option { if let Some(item_def_id) = item.as_ref().map(|item| item.item_definition_id()) { - if let Some((_unequip_time, count)) = self - .recently_unequipped_items - .get_mut(&item_def_id.to_owned()) + if let Some((_unequip_time, count)) = + self.recently_unequipped_items.get_mut(&item_def_id) { *count = count.saturating_sub(1); } diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 6bfcf29635..730e42fba9 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -910,7 +910,7 @@ impl Inventory { && self .loadout .recently_unequipped_items - .contains_key(&item.item_definition_id().to_owned()) + .contains_key(&item.item_definition_id()) }) }) .map(|(slot, _item)| slot) diff --git a/common/state/Cargo.toml b/common/state/Cargo.toml index 9ad729f934..a74ac21d53 100644 --- a/common/state/Cargo.toml +++ b/common/state/Cargo.toml @@ -22,7 +22,7 @@ tracing = { version = "0.1", default-features = false } vek = { version = "0.15.8", features = ["serde"] } # Data structures -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } # ECS specs = { version = "0.18", features = ["serde", "storage-event-control", "derive"] } diff --git a/common/systems/Cargo.toml b/common/systems/Cargo.toml index e9d91ca88e..7b094ccc1b 100644 --- a/common/systems/Cargo.toml +++ b/common/systems/Cargo.toml @@ -23,7 +23,7 @@ ordered-float = { version = "3", default-features = false } itertools = "0.10" # Data structures -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } indexmap = "1.3.0" slab = "0.4.2" diff --git a/network/Cargo.toml b/network/Cargo.toml index 4007971631..5e892e85c3 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -46,7 +46,7 @@ lz-fear = { version = "0.1.1", optional = true } async-trait = "0.1.42" bytes = "^1" # faster HashMaps -hashbrown = { version = ">=0.9, <0.13" } +hashbrown = { version = "0.13" } [dev-dependencies] tracing-subscriber = { version = "0.3.7", default-features = false, features = ["env-filter", "fmt", "time", "ansi", "smallvec"] } diff --git a/network/protocol/Cargo.toml b/network/protocol/Cargo.toml index ebc9b87e5e..0eed87d0f1 100644 --- a/network/protocol/Cargo.toml +++ b/network/protocol/Cargo.toml @@ -24,7 +24,7 @@ rand = { version = "0.8" } # async traits async-trait = "0.1.42" bytes = "^1" -hashbrown = { version = ">=0.12, <0.13" } +hashbrown = { version = "0.13" } [dev-dependencies] async-channel = "1.5.1" diff --git a/rtsim/Cargo.toml b/rtsim/Cargo.toml index 639680d709..3aafaf3624 100644 --- a/rtsim/Cargo.toml +++ b/rtsim/Cargo.toml @@ -8,7 +8,7 @@ common = { package = "veloren-common", path = "../common" } world = { package = "veloren-world", path = "../world" } ron = "0.8" serde = { version = "1.0.110", features = ["derive"] } -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } enum-map = { version = "2.4", features = ["serde"] } vek = { version = "0.15.8", features = ["serde"] } rmp-serde = "1.1.0" diff --git a/server/Cargo.toml b/server/Cargo.toml index 54347b0473..cac886931f 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -54,7 +54,7 @@ ron = { version = "0.8", default-features = false } serde = { version = "1.0.110", features = ["derive"] } serde_json = "1.0.50" rand = { version = "0.8", features = ["small_rng"] } -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } parking_lot = { version = "0.12" } rayon = "1.5" crossbeam-channel = "0.5" diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 30be0d04c7..def8ce1391 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -114,7 +114,7 @@ dot_vox = "5.1" enum-iterator = "1.1.0" guillotiere = "0.6.2" etagere = "0.2.7" -hashbrown = {version = "0.12", features = ["rayon", "serde", "nightly"]} +hashbrown = {version = "0.13", features = ["rayon", "serde", "nightly"]} image = {version = "0.24", default-features = false, features = ["ico", "png"]} lazy_static = "1.4.0" native-dialog = { version = "0.6.3", optional = true } diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index 9d6318a4ae..b610fe7d79 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -194,7 +194,7 @@ impl<'a> Widget for Group<'a> { } // Helper - let uid_to_name_text = |uid, client: &Client| match client.player_list().get(&uid) { + let uid_to_name_text = |uid: Uid, client: &Client| match client.player_list().get(&uid) { Some(player_info) => player_info .character .as_ref() diff --git a/world/Cargo.toml b/world/Cargo.toml index 0d8ed510a9..d7829ca33f 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -29,7 +29,7 @@ vek = { version = "0.15.8", features = ["serde"] } noise = { version = "0.7", default-features = false } num = "0.4" ordered-float = "3" -hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] } +hashbrown = { version = "0.13", features = ["rayon", "serde", "nightly"] } lazy_static = "1.4.0" tracing = { version = "0.1", default-features = false } rand = "0.8"