To not allocate in good case

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2025-08-17 14:44:48 +02:00 committed by Fintan Halpenny
parent 0200e84aea
commit b0af48aa03
1 changed files with 1 additions and 1 deletions

View File

@ -244,7 +244,7 @@ impl Checkout {
let proj = doc let proj = doc
.project() .project()
.map_err(|err| CheckoutFailure::Payload { rid, err })?; .map_err(|err| CheckoutFailure::Payload { rid, err })?;
let path = directory.unwrap_or(Path::new(proj.name()).to_path_buf()); let path = directory.unwrap_or_else(|| PathBuf::from(proj.name()));
// N.b. fail if the path exists and is not empty // N.b. fail if the path exists and is not empty
if path.exists() { if path.exists() {
if path.read_dir().map_or(true, |mut dir| dir.next().is_some()) { if path.read_dir().map_or(true, |mut dir| dir.next().is_some()) {