Optimize scope.

This commit is contained in:
Stephen Chung 2021-05-18 12:40:40 +08:00
parent 70f09d1c84
commit e64dad4e9f
2 changed files with 3 additions and 3 deletions

View File

@ -2128,7 +2128,7 @@ mod tests {
96
}
);
assert_eq!(size_of::<Scope>(), 288);
assert_eq!(size_of::<Scope>(), 160);
assert_eq!(size_of::<LexError>(), 56);
assert_eq!(
size_of::<ParseError>(),

View File

@ -7,7 +7,7 @@ use std::prelude::v1::*;
use std::{borrow::Cow, iter::Extend};
/// Keep a number of entries inline (since [`Dynamic`] is usually small enough).
const SCOPE_SIZE: usize = 16;
const SCOPE_SIZE: usize = 8;
/// Type containing information about the current scope.
/// Useful for keeping state between [`Engine`][crate::Engine] evaluation runs.
@ -98,7 +98,7 @@ impl<'a> Scope<'a> {
pub fn new() -> Self {
Self {
values: Default::default(),
names: Vec::with_capacity(SCOPE_SIZE),
names: Default::default(),
}
}
/// Empty the [`Scope`].