Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative name component used for faster comparisons #1109

Merged
merged 4 commits into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes ahash import and format
  • Loading branch information
lassade committed Dec 22, 2020
commit 3b64b287e50596fbd9676da8e703ddc004df4170
5 changes: 1 addition & 4 deletions crates/bevy_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.4.0" }
bevy_math = { path = "../bevy_math", version = "0.4.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.4.0", features = ["bevy"] }
bevy_tasks = { path = "../bevy_tasks", version = "0.4.0" }
bevy_utils = { path = "../bevy_utils", version = "0.4.0" }

# other
ahash = "0.6.2"
bevy_utils = { path = "../bevy_utils", version = "0.4.0" }
9 changes: 6 additions & 3 deletions crates/bevy_core/src/name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use bevy_reflect::{Reflect, ReflectComponent};
use std::hash::{Hash, Hasher};
use std::ops::Deref;
use bevy_utils::AHasher;
use std::{
hash::{Hash, Hasher},
ops::Deref,
};

/// Component used to identify a entity. Stores a hash for faster comparisons
#[derive(Debug, Clone, Reflect)]
Expand Down Expand Up @@ -45,7 +48,7 @@ impl Name {
}

fn update_hash(&mut self) {
let mut hasher = ahash::AHasher::default();
let mut hasher = AHasher::default();
self.name.hash(&mut hasher);
self.hash = hasher.finish();
}
Expand Down