diff options
| author | mo8it <mo8it@proton.me> | 2024-03-25 03:59:21 +0100 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-03-25 03:59:21 +0100 |
| commit | d095a307ddbdef1f67e89320491c76a1bed1c8eb (patch) | |
| tree | 4f99aa4ef7433fc290db2bb8c142a30714137c71 /src/project.rs | |
| parent | 51712cc19f97972f470c4d8791974f8eaba095d1 (diff) | |
Avoid allocations on every call to Path::join
Diffstat (limited to 'src/project.rs')
| -rw-r--r-- | src/project.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/project.rs b/src/project.rs index a7414d1..c017aa2 100644 --- a/src/project.rs +++ b/src/project.rs @@ -3,7 +3,7 @@ use glob::glob; use serde::{Deserialize, Serialize}; use std::env; use std::error::Error; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::Command; /// Contains the structure of resulting rust-project.json file @@ -45,15 +45,9 @@ impl RustAnalyzerProject { println!("Determined toolchain: {toolchain}\n"); - let Ok(sysroot_src) = Path::new(toolchain) - .join("lib") - .join("rustlib") - .join("src") - .join("rust") - .join("library") - .into_os_string() - .into_string() - else { + let mut sysroot_src = PathBuf::with_capacity(256); + sysroot_src.extend([toolchain, "lib", "rustlib", "src", "rust", "library"]); + let Ok(sysroot_src) = sysroot_src.into_os_string().into_string() else { bail!("The sysroot path is invalid UTF8"); }; |
