Make Scope Clone + Hash.
This commit is contained in:
parent
9fd7e01197
commit
c81a59435b
@ -14,6 +14,11 @@ Breaking changes
|
|||||||
* `Engine::register_module` is renamed `Engine::register_static_module` and now must explicitly pass a shared [`Module`].
|
* `Engine::register_module` is renamed `Engine::register_static_module` and now must explicitly pass a shared [`Module`].
|
||||||
* `Package::get` is renamed `Package::as_shared_module`.
|
* `Package::get` is renamed `Package::as_shared_module`.
|
||||||
|
|
||||||
|
Enhancements
|
||||||
|
------------
|
||||||
|
|
||||||
|
* `Scope` is now `Clone + Hash`.
|
||||||
|
|
||||||
|
|
||||||
Version 0.19.8
|
Version 0.19.8
|
||||||
==============
|
==============
|
||||||
|
11
src/scope.rs
11
src/scope.rs
@ -39,17 +39,16 @@ use crate::{Dynamic, ImmutableString, StaticVec};
|
|||||||
// # Implementation Notes
|
// # Implementation Notes
|
||||||
//
|
//
|
||||||
// [`Scope`] is implemented as two [`Vec`]'s of exactly the same length. Variables data (name, type, etc.)
|
// [`Scope`] is implemented as two [`Vec`]'s of exactly the same length. Variables data (name, type, etc.)
|
||||||
// is manually split into three equal-length arrays. That's because variable names take up the most space,
|
// is manually split into two equal-length arrays. That's because variable names take up the most space,
|
||||||
// with [`Cow<str>`][Cow] being four words long, but in the vast majority of cases the name is NOT used to look up
|
// with [`Cow<str>`][Cow] being four words long, but in the vast majority of cases the name is NOT used to
|
||||||
// a variable's value. Variable lookup is usually via direct index, by-passing the name altogether.
|
/// look up a variable. Variable lookup is usually via direct indexing, by-passing the name altogether.
|
||||||
//
|
//
|
||||||
// Since [`Dynamic`] is reasonably small, packing it tightly improves cache locality when variables are accessed.
|
// Since [`Dynamic`] is reasonably small, packing it tightly improves cache locality when variables are accessed.
|
||||||
// The variable type is packed separately into another array because it is even smaller.
|
#[derive(Debug, Clone, Hash)]
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Scope<'a> {
|
pub struct Scope<'a> {
|
||||||
/// Current value of the entry.
|
/// Current value of the entry.
|
||||||
values: Vec<Dynamic>,
|
values: Vec<Dynamic>,
|
||||||
/// (Name, aliases) of the entry. The list of aliases is Boxed because it occurs rarely.
|
/// (Name, aliases) of the entry.
|
||||||
names: Vec<(Cow<'a, str>, Box<StaticVec<ImmutableString>>)>,
|
names: Vec<(Cow<'a, str>, Box<StaticVec<ImmutableString>>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user