Skip to content

Commit

Permalink
Avoid allocations on every call to Path::join
Browse files Browse the repository at this point in the history
  • Loading branch information
mo8it committed Mar 25, 2024
1 parent 51712cc commit d095a30
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
};

Expand Down

0 comments on commit d095a30

Please sign in to comment.