mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Make get_env_var
return a reference to a Value
(#13987)
# Description Title says it all, changes `EngineState::get_env_var` to return a `Option<&'a Value>` instead of an owned `Option<Value>`. This avoids some unnecessary clones. I also made a similar change to the `PluginExecutionContext` trait.
This commit is contained in:
@ -95,8 +95,9 @@ pub(crate) fn get_plugin_dirs(
|
||||
let working_set = StateWorkingSet::new(engine_state);
|
||||
let value = working_set
|
||||
.find_variable(b"$NU_PLUGIN_DIRS")
|
||||
.and_then(|var_id| working_set.get_constant(var_id).ok().cloned())
|
||||
.or_else(|| stack.get_env_var(engine_state, "NU_PLUGIN_DIRS"));
|
||||
.and_then(|var_id| working_set.get_constant(var_id).ok())
|
||||
.or_else(|| stack.get_env_var(engine_state, "NU_PLUGIN_DIRS"))
|
||||
.cloned(); // TODO: avoid this clone
|
||||
|
||||
// Get all of the strings in the list, if possible
|
||||
value
|
||||
|
Reference in New Issue
Block a user