History

Optimize `clone::PrepareCheckout::main_worktree``

Use `DynNestedProgress` instead of `NestedProgress`, although this also require `<P as NestedProgress>::SubProgress: 'static` which is a breaking change.

Jiahao XU committed 3 years ago

Commit 938f5181 parent 1b1fc251 file · +16 −4Browse files

Unified · Split

gix/src/clone/checkout.rs+16−4
@@ -62,9 +62,21 @@ pub mod main_worktree { · 61 unmodified lines
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, SubP>(
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<SubProgress = SubP>,
72+ SubP: 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 { · 25 unmodified lines
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());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t