mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 00:48:59 +02:00
Shrink Value
by boxing Range
/Closure
(#12784)
# Description On 64-bit platforms the current size of `Value` is 56 bytes. The limiting variants were `Closure` and `Range`. Boxing the two reduces the size of Value to 48 bytes. This is the minimal size possible with our current 16-byte `Span` and any 24-byte `Vec` container which we use in several variants. (Note the extra full 8-bytes necessary for the discriminant or other smaller values due to the 8-byte alignment of `usize`) This is leads to a size reduction of ~15% for `Value` and should overall be beneficial as both `Range` and `Closure` are rarely used compared to the primitive types or even our general container types. # User-Facing Changes Less memory used, potential runtime benefits. (Too late in the evening to run the benchmarks myself right now)
This commit is contained in:
committed by
GitHub
parent
92831d7efc
commit
ba6f38510c
@ -106,7 +106,7 @@ impl<'a> PluginExecutionContext for PluginExecutionCommandContext<'a> {
|
||||
let span = value.span();
|
||||
match value {
|
||||
Value::Closure { val, .. } => {
|
||||
ClosureEvalOnce::new(&self.engine_state, &self.stack, val)
|
||||
ClosureEvalOnce::new(&self.engine_state, &self.stack, *val)
|
||||
.run_with_input(PipelineData::Empty)
|
||||
.map(|data| data.into_value(span))
|
||||
.unwrap_or_else(|err| Value::error(err, self.call.head))
|
||||
|
Reference in New Issue
Block a user