forked from extern/nushell
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:
@@ -1276,7 +1276,9 @@ pub(crate) fn handle_engine_call(
|
||||
}
|
||||
EngineCall::GetEnvVar(name) => {
|
||||
let value = context.get_env_var(&name)?;
|
||||
Ok(value.map_or_else(EngineCallResponse::empty, EngineCallResponse::value))
|
||||
Ok(value
|
||||
.cloned()
|
||||
.map_or_else(EngineCallResponse::empty, EngineCallResponse::value))
|
||||
}
|
||||
EngineCall::GetEnvVars => context.get_env_vars().map(EngineCallResponse::ValueMap),
|
||||
EngineCall::GetCurrentDir => {
|
||||
|
Reference in New Issue
Block a user