diff --git a/RELEASES.md b/RELEASES.md index 2e9a14e5..33680b02 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -14,6 +14,11 @@ Breaking changes * `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`. +Enhancements +------------ + +* `Scope` is now `Clone + Hash`. + Version 0.19.8 ============== diff --git a/src/scope.rs b/src/scope.rs index 4e5cc08a..6695ab0a 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -39,17 +39,16 @@ use crate::{Dynamic, ImmutableString, StaticVec}; // # Implementation Notes // // [`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, -// with [`Cow`][Cow] being four words long, but in the vast majority of cases the name is NOT used to look up -// a variable's value. Variable lookup is usually via direct index, by-passing the name altogether. +// is manually split into two equal-length arrays. That's because variable names take up the most space, +// with [`Cow`][Cow] being four words long, but in the vast majority of cases the name is NOT used to +/// 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. -// The variable type is packed separately into another array because it is even smaller. -#[derive(Debug)] +#[derive(Debug, Clone, Hash)] pub struct Scope<'a> { /// Current value of the entry. values: Vec, - /// (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>)>, }