Skip to content

Commit 6cf39a8

Browse files
author
Stephan Dilly
authored
Fix 1102 performance reg (#1103)
1 parent acb7e52 commit 6cf39a8

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
* severe performance regression ([#1102](https://github.com/extrawurst/gitui/1102))
12+
* windows release deployment via CD broken
13+
1014
## [0.20] - 2021-01-25 - Tag Annotations
1115

1216
**support tag annotations**

src/tabs/status.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use anyhow::Result;
1515
use asyncgit::{
1616
cached,
1717
sync::{
18-
self, get_branches_info, status::StatusType, RepoPath,
19-
RepoPathRef, RepoState,
18+
self, status::StatusType, RepoPath, RepoPathRef, RepoState,
2019
},
2120
sync::{BranchCompare, CommitId},
2221
AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams,
@@ -67,6 +66,7 @@ pub struct Status {
6766
index_wd: ChangesComponent,
6867
diff: DiffComponent,
6968
git_diff: AsyncDiff,
69+
has_remotes: bool,
7070
git_status_workdir: AsyncStatus,
7171
git_status_stage: AsyncStatus,
7272
git_branch_state: Option<BranchCompare>,
@@ -161,6 +161,7 @@ impl Status {
161161
Self {
162162
queue: queue.clone(),
163163
visible: true,
164+
has_remotes: false,
164165
focus: Focus::WorkDir,
165166
diff_target: DiffTarget::WorkingDir,
166167
index_wd: ChangesComponent::new(
@@ -422,6 +423,13 @@ impl Status {
422423
|| self.git_status_workdir.is_pending()
423424
}
424425

426+
fn check_remotes(&mut self) {
427+
self.has_remotes =
428+
sync::get_branches_info(&self.repo.borrow(), false)
429+
.map(|branches| !branches.is_empty())
430+
.unwrap_or(false);
431+
}
432+
425433
///
426434
pub fn update_git(
427435
&mut self,
@@ -568,12 +576,6 @@ impl Status {
568576
}
569577
}
570578

571-
fn has_remotes(&self) -> bool {
572-
get_branches_info(&self.repo.borrow(), false)
573-
.map(|l| !l.is_empty())
574-
.unwrap_or(false)
575-
}
576-
577579
fn pull(&self) {
578580
if let Some(branch) = self.git_branch_name.last() {
579581
self.queue.push(InternalEvent::Pull(branch));
@@ -603,11 +605,11 @@ impl Status {
603605
self.git_branch_state
604606
.as_ref()
605607
.map_or(true, |state| state.ahead > 0)
606-
&& self.has_remotes()
608+
&& self.has_remotes
607609
}
608610

609-
fn can_pull(&self) -> bool {
610-
self.has_remotes() && self.git_branch_state.is_some()
611+
const fn can_pull(&self) -> bool {
612+
self.has_remotes && self.git_branch_state.is_some()
611613
}
612614

613615
fn can_abort_merge(&self) -> bool {
@@ -937,6 +939,7 @@ impl Component for Status {
937939

938940
fn show(&mut self) -> Result<()> {
939941
self.visible = true;
942+
self.check_remotes();
940943
self.update()?;
941944

942945
Ok(())

0 commit comments

Comments
 (0)