Switch to fxhash for fast hashing.

This commit is contained in:
Stephen Chung 2021-01-15 23:30:45 +08:00
parent 9e2c1a5860
commit 1c7884f0d8
3 changed files with 6 additions and 3 deletions

View File

@ -23,7 +23,8 @@ keywords = [ "scripting" ]
categories = [ "no-std", "embedded", "wasm", "parser-implementations" ]
[dependencies]
smallvec = { version = "1.4.2", default-features = false }
smallvec = { version = "1.4", default-features = false }
fxhash = { version = "0.2" }
rhai_codegen = { version = "0.3", path = "codegen" }
[features]

View File

@ -35,7 +35,7 @@ Standard features
* Freely pass Rust variables/constants into a script via an external [`Scope`](https://rhaiscript.github.io/book/rust/scope.html) - all clonable Rust types are supported; no need to implement any special trait.
* Easily [call a script-defined function](https://rhaiscript.github.io/book/engine/call-fn.html) from Rust.
* Relatively little `unsafe` code (yes there are some for performance reasons).
* Few dependencies (currently only [`smallvec`](https://crates.io/crates/smallvec)).
* Few dependencies (currently only [`smallvec`](https://crates.io/crates/smallvec) and [`fxhash`](https://crates.io/crates/fxhash)).
* Re-entrant scripting engine can be made `Send + Sync` (via the `sync` feature).
* Scripts are [optimized](https://rhaiscript.github.io/book/engine/optimize.html) (useful for template-based machine-generated scripts) for repeated evaluations.
* Easy custom API development via [plugins](https://rhaiscript.github.io/book/plugins/index.html) system powered by procedural macros.

View File

@ -61,8 +61,10 @@ impl BuildHasher for StraightHasherBuilder {
pub fn get_hasher() -> impl Hasher {
#[cfg(feature = "no_std")]
let s: ahash::AHasher = Default::default();
// #[cfg(not(feature = "no_std"))]
// let s = crate::stdlib::collections::hash_map::DefaultHasher::new();
#[cfg(not(feature = "no_std"))]
let s = crate::stdlib::collections::hash_map::DefaultHasher::new();
let s: fxhash::FxHasher64 = Default::default();
s
}