mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 00:18:28 +02:00
Avoid taking unnecessary ownership of intermediates (#12740)
# Description Judiciously try to avoid allocations/clone by changing the signature of functions - **Don't pass str by value unnecessarily if only read** - **Don't require a vec in `Sandbox::with_files`** - **Remove unnecessary string clone** - **Fixup unnecessary borrow** - **Use `&str` in shape color instead** - **Vec -> Slice** - **Elide string clone** - **Elide `Path` clone** - **Take &str to elide clone in tests** # User-Facing Changes None # Tests + Formatting This touches many tests purely in changing from owned to borrowed/static data
This commit is contained in:
committed by
GitHub
parent
e6f473695c
commit
406df7f208
@ -57,7 +57,7 @@ impl Command for ConfigEnv {
|
||||
|
||||
let env_vars_str = env_to_strings(engine_state, stack)?;
|
||||
let nu_config = match engine_state.get_config_path("env-path") {
|
||||
Some(path) => path.clone(),
|
||||
Some(path) => path,
|
||||
None => {
|
||||
return Err(ShellError::GenericError {
|
||||
error: "Could not find $nu.env-path".into(),
|
||||
|
@ -61,7 +61,7 @@ impl Command for ConfigNu {
|
||||
|
||||
let env_vars_str = env_to_strings(engine_state, stack)?;
|
||||
let nu_config = match engine_state.get_config_path("config-path") {
|
||||
Some(path) => path.clone(),
|
||||
Some(path) => path,
|
||||
None => {
|
||||
return Err(ShellError::GenericError {
|
||||
error: "Could not find $nu.config-path".into(),
|
||||
|
4
crates/nu-command/src/env/config/utils.rs
vendored
4
crates/nu-command/src/env/config/utils.rs
vendored
@ -1,10 +1,10 @@
|
||||
use crate::ExternalCommand;
|
||||
use nu_protocol::{OutDest, Span, Spanned};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
pub(crate) fn gen_command(
|
||||
span: Span,
|
||||
config_path: PathBuf,
|
||||
config_path: &Path,
|
||||
item: String,
|
||||
config_args: Vec<String>,
|
||||
env_vars_str: HashMap<String, String>,
|
||||
|
Reference in New Issue
Block a user