mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
rewrite: avoid accessing MutRepo::view()
when rebasing descendants
Since 94e03f5ac8
, we lazily filter out non-heads from `View`'s set
of head. Accessing the `MutRepo::view()` triggers that filtering. This
patch makes `DescendantRebaser` not unnecessarily do that. That speeds
up the rebasing of 162 descendants in the git.git repo from ~3.6 s to
~330 ms. Rebasing 1272 descendants takes ~885 ms.
This commit is contained in:
parent
f084a05c0e
commit
c058ffeed7
2 changed files with 6 additions and 3 deletions
|
@ -528,6 +528,10 @@ impl MutableRepo {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_checkout(&mut self) -> CommitId {
|
||||
self.view.borrow().checkout().clone()
|
||||
}
|
||||
|
||||
pub fn set_checkout(&mut self, id: CommitId) {
|
||||
self.view_mut().set_checkout(id);
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
|
|||
}
|
||||
|
||||
fn update_references(&mut self, old_commit_id: CommitId, new_commit_ids: Vec<CommitId>) {
|
||||
if *self.mut_repo.view().checkout() == old_commit_id {
|
||||
if self.mut_repo.get_checkout() == old_commit_id {
|
||||
// We arbitrarily pick a new checkout among the candidates.
|
||||
let new_commit_id = new_commit_ids[0].clone();
|
||||
let new_commit = self.mut_repo.store().get_commit(&new_commit_id).unwrap();
|
||||
|
@ -272,10 +272,9 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
|
|||
}
|
||||
|
||||
if let Some(branch_names) = self.branches.get(&old_commit_id) {
|
||||
let view = self.mut_repo.view();
|
||||
let mut branch_updates = vec![];
|
||||
for branch_name in branch_names {
|
||||
let local_target = view.get_local_branch(branch_name).unwrap();
|
||||
let local_target = self.mut_repo.get_local_branch(branch_name).unwrap();
|
||||
for old_add in local_target.adds() {
|
||||
if old_add == old_commit_id {
|
||||
branch_updates.push((branch_name.clone(), true));
|
||||
|
|
Loading…
Reference in a new issue