From 896dd56b7af06fea6604a5596a6ffd17e7e52e6e Mon Sep 17 00:00:00 2001 From: Yiyu Lin Date: Fri, 6 Jan 2023 03:29:50 +0800 Subject: refactor(cli,core,ext,rt): remove some unnecessary `clone` or `malloc` (#17274) --- cli/tools/vendor/test.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli/tools/vendor/test.rs') diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs index 61c885731..7171b8463 100644 --- a/cli/tools/vendor/test.rs +++ b/cli/tools/vendor/test.rs @@ -242,7 +242,7 @@ impl VendorTestBuilder { let import_map = files.remove(&output_dir.join("import_map.json")); let mut files = files .iter() - .map(|(path, text)| (path_to_string(path), text.clone())) + .map(|(path, text)| (path_to_string(path), text.to_string())) .collect::>(); files.sort_by(|a, b| a.0.cmp(&b.0)); @@ -293,7 +293,11 @@ fn make_path(text: &str) -> PathBuf { } } -fn path_to_string(path: &Path) -> String { +fn path_to_string

(path: P) -> String +where + P: AsRef, +{ + let path = path.as_ref(); // inverse of the function above let path = path.to_string_lossy(); if cfg!(windows) { -- cgit v1.2.3