mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 18:27:38 +00:00
MutableRepo: don't calculate evolution state only to update it
This commit is contained in:
parent
f0619c07ac
commit
12a47bd6ed
1 changed files with 10 additions and 8 deletions
|
@ -544,15 +544,13 @@ impl<'r> MutableRepo<'r> {
|
||||||
unsafe { std::mem::transmute(evolution) }
|
unsafe { std::mem::transmute(evolution) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evolution_mut(&mut self) -> &mut MutableEvolution {
|
pub fn evolution_mut(&mut self) -> Option<&mut MutableEvolution> {
|
||||||
let mut locked_evolution = self.evolution.lock().unwrap();
|
let mut locked_evolution = self.evolution.lock().unwrap();
|
||||||
if locked_evolution.is_none() {
|
let maybe_evolution = locked_evolution.as_mut();
|
||||||
locked_evolution.replace(MutableEvolution::new(self));
|
|
||||||
}
|
|
||||||
// Extend lifetime from lifetime of MutexGuard to lifetime of self. Safe because
|
// Extend lifetime from lifetime of MutexGuard to lifetime of self. Safe because
|
||||||
// the value won't change again except for by invalidate_evolution(), which
|
// the value won't change again except for by invalidate_evolution(), which
|
||||||
// requires a mutable reference.
|
// requires a mutable reference.
|
||||||
unsafe { std::mem::transmute(locked_evolution.as_mut().unwrap()) }
|
unsafe { std::mem::transmute(maybe_evolution) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn invalidate_evolution(&mut self) {
|
pub fn invalidate_evolution(&mut self) {
|
||||||
|
@ -625,7 +623,9 @@ impl<'r> MutableRepo<'r> {
|
||||||
{
|
{
|
||||||
self.index.add_commit(head);
|
self.index.add_commit(head);
|
||||||
self.view.add_head(head);
|
self.view.add_head(head);
|
||||||
self.evolution_mut().add_commit(head);
|
if let Some(evolution) = self.evolution_mut() {
|
||||||
|
evolution.add_commit(head)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let missing_commits = topo_order_reverse(
|
let missing_commits = topo_order_reverse(
|
||||||
vec![head.clone()],
|
vec![head.clone()],
|
||||||
|
@ -653,7 +653,9 @@ impl<'r> MutableRepo<'r> {
|
||||||
|
|
||||||
pub fn add_public_head(&mut self, head: &Commit) {
|
pub fn add_public_head(&mut self, head: &Commit) {
|
||||||
self.view.add_public_head(head);
|
self.view.add_public_head(head);
|
||||||
self.evolution_mut().add_commit(head);
|
if let Some(evolution) = self.evolution_mut() {
|
||||||
|
evolution.add_commit(head)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_public_head(&mut self, head: &Commit) {
|
pub fn remove_public_head(&mut self, head: &Commit) {
|
||||||
|
|
Loading…
Reference in a new issue