chore: apply reviewers comment
This commit is contained in:
parent
239438754c
commit
d515eaf7cd
@ -27,6 +27,7 @@ rhai_codegen = { version = "1.4.1", path = "codegen", default-features = false }
|
|||||||
|
|
||||||
no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
|
no-std-compat = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
|
||||||
libm = { version = "0.2", default-features = false, optional = true }
|
libm = { version = "0.2", default-features = false, optional = true }
|
||||||
|
hashbrown = { version = "0.12", optional = true }
|
||||||
core-error = { version = "0.0", default-features = false, features = ["alloc"], optional = true }
|
core-error = { version = "0.0", default-features = false, features = ["alloc"], optional = true }
|
||||||
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
|
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
|
||||||
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
|
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
|
||||||
@ -63,7 +64,7 @@ debugging = ["internals"] # enable debugging
|
|||||||
serde = ["dep:serde", "smartstring/serde", "smallvec/serde"] # implement serde for rhai types
|
serde = ["dep:serde", "smartstring/serde", "smallvec/serde"] # implement serde for rhai types
|
||||||
|
|
||||||
# compiling for no-std
|
# compiling for no-std
|
||||||
no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "ahash/compile-time-rng"]
|
no_std = ["no-std-compat", "num-traits/libm", "core-error", "libm", "ahash/compile-time-rng", "hashbrown"]
|
||||||
|
|
||||||
# compiling for WASM
|
# compiling for WASM
|
||||||
wasm-bindgen = ["instant/wasm-bindgen"]
|
wasm-bindgen = ["instant/wasm-bindgen"]
|
||||||
|
@ -10,6 +10,9 @@ use crate::func::{
|
|||||||
};
|
};
|
||||||
use crate::types::dynamic::AccessMode;
|
use crate::types::dynamic::AccessMode;
|
||||||
use crate::{Dynamic, Engine, Module, Position, RhaiResult, RhaiResultOf, Scope, ERR};
|
use crate::{Dynamic, Engine, Module, Position, RhaiResult, RhaiResultOf, Scope, ERR};
|
||||||
|
#[cfg(feature = "no_std")]
|
||||||
|
use hashbrown::hash_map::Entry;
|
||||||
|
#[cfg(not(feature = "no_std"))]
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
|
@ -4,12 +4,18 @@
|
|||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
collections::{HashMap, HashSet},
|
|
||||||
hash::{BuildHasher, Hash, Hasher},
|
hash::{BuildHasher, Hash, Hasher},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type StraightHashMap<K, V> = HashMap<K, V, StraightHasherBuilder>;
|
#[cfg(feature = "no_std")]
|
||||||
pub type StraightHashSet<K> = HashSet<K, StraightHasherBuilder>;
|
pub type StraightHashMap<K, V> = hashbrown::HashMap<K, V, StraightHasherBuilder>;
|
||||||
|
#[cfg(feature = "no_std")]
|
||||||
|
pub type StraightHashSet<K> = hashbrown::HashSet<K, StraightHasherBuilder>;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "no_std"))]
|
||||||
|
pub type StraightHashMap<K, V> = std::collections::HashMap<K, V, StraightHasherBuilder>;
|
||||||
|
#[cfg(not(feature = "no_std"))]
|
||||||
|
pub type StraightHashSet<K> = std::collections::HashSet<K, StraightHasherBuilder>;
|
||||||
|
|
||||||
/// Dummy hash value to map zeros to. This value can be anything.
|
/// Dummy hash value to map zeros to. This value can be anything.
|
||||||
///
|
///
|
||||||
@ -47,7 +53,11 @@ impl Hasher for StraightHasher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write_u64(&mut self, i: u64) {
|
fn write_u64(&mut self, i: u64) {
|
||||||
self.0 = i;
|
if i == 0 {
|
||||||
|
self.0 = ALT_ZERO_HASH;
|
||||||
|
} else {
|
||||||
|
self.0 = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user