mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 04:48:20 +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
@ -26,7 +26,7 @@ fn chooses_highest_increment_if_given_more_than_one() {
|
||||
#[test]
|
||||
fn by_one_with_field_passed() {
|
||||
Playground::setup("plugin_inc_test_1", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
@ -47,7 +47,7 @@ fn by_one_with_field_passed() {
|
||||
#[test]
|
||||
fn by_one_with_no_field_passed() {
|
||||
Playground::setup("plugin_inc_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
@ -68,7 +68,7 @@ fn by_one_with_no_field_passed() {
|
||||
#[test]
|
||||
fn semversion_major_inc() {
|
||||
Playground::setup("plugin_inc_test_3", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
@ -89,7 +89,7 @@ fn semversion_major_inc() {
|
||||
#[test]
|
||||
fn semversion_minor_inc() {
|
||||
Playground::setup("plugin_inc_test_4", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
@ -110,7 +110,7 @@ fn semversion_minor_inc() {
|
||||
#[test]
|
||||
fn semversion_patch_inc() {
|
||||
Playground::setup("plugin_inc_test_5", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
@ -131,7 +131,7 @@ fn semversion_patch_inc() {
|
||||
#[test]
|
||||
fn semversion_without_passing_field() {
|
||||
Playground::setup("plugin_inc_test_6", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContent(
|
||||
sandbox.with_files(&[FileWithContent(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
|
Reference in New Issue
Block a user