mirror of
https://github.com/nushell/nushell.git
synced 2025-08-20 02:38:42 +02:00
Use Vec for Closure captures (#10940)
# Description Changes the `captures` field in `Closure` from a `HashMap` to a `Vec` and makes `Stack::captures_to_stack` take an owned `Vec` instead of a borrowed `HashMap`. This eliminates the conversion to a `Vec` inside `captures_to_stack` and makes it possible to avoid clones altogether when using an owned `Closure` (which is the case for most commands). Additionally, using a `Vec` reduces the size of `Value` by 8 bytes (down to 72). # User-Facing Changes Breaking API change for `nu-protocol`.
This commit is contained in:
@@ -182,7 +182,7 @@ mod test {
|
||||
ast::{CellPath, PathMember},
|
||||
engine::Closure,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn from_value() {
|
||||
@@ -243,7 +243,7 @@ mod test {
|
||||
Value::closure(
|
||||
Closure {
|
||||
block_id: 0,
|
||||
captures: HashMap::new(),
|
||||
captures: Vec::new(),
|
||||
},
|
||||
span,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user