forked from extern/nushell
Reuse existing small allocations if possible (#12335)
Those allocations are all small and insignificant in the grand scheme of things and the optimizer may be able to resolve some of those but better to be nice anyways. Primarily inspired by the new [`clippy::assigning_clones`](https://rust-lang.github.io/rust-clippy/master/index.html#/assigning_clones) - **Avoid reallocs with `clone_from` in `nu-parser`** - **Avoid realloc on assignment in `Stack`** - **Fix `clippy::assigning_clones` in `nu-cli`** - **Reuse allocations in `nu-explore` if possible**
This commit is contained in:
committed by
GitHub
parent
ce581a80a6
commit
cc39069e13
@ -137,11 +137,11 @@ impl Stack {
|
||||
) {
|
||||
// Do not clone the environment if it hasn't changed
|
||||
if self.env_vars.iter().any(|scope| !scope.is_empty()) {
|
||||
self.env_vars = env_vars.to_owned();
|
||||
env_vars.clone_into(&mut self.env_vars);
|
||||
}
|
||||
|
||||
if !self.env_hidden.is_empty() {
|
||||
self.env_hidden = env_hidden.to_owned();
|
||||
self.env_hidden.clone_from(env_hidden);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user