From e64dad4e9f95f7dae8e98b0371f24bc7ee3066f7 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 18 May 2021 12:40:40 +0800 Subject: [PATCH] Optimize scope. --- src/ast.rs | 2 +- src/scope.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 21841502..aa1a1a4a 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -2128,7 +2128,7 @@ mod tests { 96 } ); - assert_eq!(size_of::(), 288); + assert_eq!(size_of::(), 160); assert_eq!(size_of::(), 56); assert_eq!( size_of::(), diff --git a/src/scope.rs b/src/scope.rs index ed0bacd1..3c34cb09 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -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`].