mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 23:32:41 +00:00
working_copy: use RepoPath::parent() which no longer allocates temporary object
This commit is contained in:
parent
016fc2b5cc
commit
bc9725c73c
1 changed files with 2 additions and 6 deletions
|
@ -301,13 +301,9 @@ fn create_parent_dirs(
|
||||||
working_copy_path: &Path,
|
working_copy_path: &Path,
|
||||||
repo_path: &RepoPath,
|
repo_path: &RepoPath,
|
||||||
) -> Result<bool, CheckoutError> {
|
) -> Result<bool, CheckoutError> {
|
||||||
// TODO: make RepoPath::parent() cheap and use it instead
|
let parent_path = repo_path.parent().expect("repo path shouldn't be root");
|
||||||
let mut dir_components = repo_path.components();
|
|
||||||
dir_components
|
|
||||||
.next_back()
|
|
||||||
.expect("repo path shouldn't be root");
|
|
||||||
let mut dir_path = working_copy_path.to_owned();
|
let mut dir_path = working_copy_path.to_owned();
|
||||||
for c in dir_components {
|
for c in parent_path.components() {
|
||||||
dir_path.push(c.as_str());
|
dir_path.push(c.as_str());
|
||||||
match fs::create_dir(&dir_path) {
|
match fs::create_dir(&dir_path) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
|
|
Loading…
Reference in a new issue