summaryrefslogtreecommitdiffstats
path: root/src/tabs
diff options
context:
space:
mode:
authorStephan Dilly <dilly.stephan@gmail.com>2022-01-26 00:30:19 +0100
committerGitHub <noreply@github.com>2022-01-26 00:30:19 +0100
commit6cf39a88f5596b05851c29a2de461b8b186c9767 (patch)
tree7ffe3fc6d411c87d0da78a58ba8ea5472344f49d /src/tabs
parentacb7e5269677a1832ddc5d644e98b2361584e1c0 (diff)
Fix 1102 performance reg (#1103)
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/status.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/tabs/status.rs b/src/tabs/status.rs
index 52b91358..fda6919e 100644
--- a/src/tabs/status.rs
+++ b/src/tabs/status.rs
@@ -15,8 +15,7 @@ use anyhow::Result;
use asyncgit::{
cached,
sync::{
- self, get_branches_info, status::StatusType, RepoPath,
- RepoPathRef, RepoState,
+ self, status::StatusType, RepoPath, RepoPathRef, RepoState,
},
sync::{BranchCompare, CommitId},
AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams,
@@ -67,6 +66,7 @@ pub struct Status {
index_wd: ChangesComponent,
diff: DiffComponent,
git_diff: AsyncDiff,
+ has_remotes: bool,
git_status_workdir: AsyncStatus,
git_status_stage: AsyncStatus,
git_branch_state: Option<BranchCompare>,
@@ -161,6 +161,7 @@ impl Status {
Self {
queue: queue.clone(),
visible: true,
+ has_remotes: false,
focus: Focus::WorkDir,
diff_target: DiffTarget::WorkingDir,
index_wd: ChangesComponent::new(
@@ -422,6 +423,13 @@ impl Status {
|| self.git_status_workdir.is_pending()
}
+ fn check_remotes(&mut self) {
+ self.has_remotes =
+ sync::get_branches_info(&self.repo.borrow(), false)
+ .map(|branches| !branches.is_empty())
+ .unwrap_or(false);
+ }
+
///
pub fn update_git(
&mut self,
@@ -568,12 +576,6 @@ impl Status {
}
}
- fn has_remotes(&self) -> bool {
- get_branches_info(&self.repo.borrow(), false)
- .map(|l| !l.is_empty())
- .unwrap_or(false)
- }
-
fn pull(&self) {
if let Some(branch) = self.git_branch_name.last() {
self.queue.push(InternalEvent::Pull(branch));
@@ -603,11 +605,11 @@ impl Status {
self.git_branch_state
.as_ref()
.map_or(true, |state| state.ahead > 0)
- && self.has_remotes()
+ && self.has_remotes
}
- fn can_pull(&self) -> bool {
- self.has_remotes() && self.git_branch_state.is_some()
+ const fn can_pull(&self) -> bool {
+ self.has_remotes && self.git_branch_state.is_some()
}
fn can_abort_merge(&self) -> bool {
@@ -937,6 +939,7 @@ impl Component for Status {
fn show(&mut self) -> Result<()> {
self.visible = true;
+ self.check_remotes();
self.update()?;
Ok(())