Skip to content

Commit 14312b6

Browse files
authored
Merge pull request #1015 from NobodyXu/optimize/prepare-checkout
Optimize `clone::PrepareCheckout::main_worktree``
2 parents 9c528dc + ee9276f commit 14312b6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

gix/src/clone/checkout.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,21 @@ pub mod main_worktree {
6262
///
6363
/// Note that this is a no-op if the remote was empty, leaving this repository empty as well. This can be validated by checking
6464
/// if the `head()` of the returned repository is not unborn.
65-
pub fn main_worktree(
65+
pub fn main_worktree<P>(
6666
&mut self,
67-
mut progress: impl gix_features::progress::NestedProgress,
67+
mut progress: P,
68+
should_interrupt: &AtomicBool,
69+
) -> Result<(Repository, gix_worktree_state::checkout::Outcome), Error>
70+
where
71+
P: gix_features::progress::NestedProgress,
72+
P::SubProgress: gix_features::progress::NestedProgress + 'static,
73+
{
74+
self.main_worktree_inner(&mut progress, should_interrupt)
75+
}
76+
77+
fn main_worktree_inner(
78+
&mut self,
79+
progress: &mut dyn gix_features::progress::DynNestedProgress,
6880
should_interrupt: &AtomicBool,
6981
) -> Result<(Repository, gix_worktree_state::checkout::Outcome), Error> {
7082
let _span = gix_trace::coarse!("gix::clone::PrepareCheckout::main_worktree()");
@@ -96,8 +108,8 @@ pub mod main_worktree {
96108
.checkout_options(repo, gix_worktree::stack::state::attributes::Source::IdMapping)?;
97109
opts.destination_is_initially_empty = true;
98110

99-
let mut files = progress.add_child_with_id("checkout", ProgressId::CheckoutFiles.into());
100-
let mut bytes = progress.add_child_with_id("writing", ProgressId::BytesWritten.into());
111+
let mut files = progress.add_child_with_id("checkout".to_string(), ProgressId::CheckoutFiles.into());
112+
let mut bytes = progress.add_child_with_id("writing".to_string(), ProgressId::BytesWritten.into());
101113

102114
files.init(Some(index.entries().len()), crate::progress::count("files"));
103115
bytes.init(None, crate::progress::bytes());

0 commit comments

Comments
 (0)