Skip to content

Commit 0b48e6f

Browse files
author
Stephan Dilly
authored
fix tags being fetched every scroll in revlog (gitui-org#851)
1 parent 55f224c commit 0b48e6f

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
## Fixed
2020
- do not allow to ignore .gitignore files ([#825](https://github.com/extrawurst/gitui/issues/825))
2121
- crash in shallow repo ([#836](https://github.com/extrawurst/gitui/issues/836))
22+
- fixed performance regression in revlog ([#850](https://github.com/extrawurst/gitui/issues/850))
2223

2324
## [0.16.2] - 2021-07-10
2425

asyncgit/src/tags.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ impl AsyncTags {
6666
) -> Result<()> {
6767
log::trace!("request");
6868

69-
if !force && (self.is_pending() || !self.is_outdated(dur)?) {
69+
if !force && self.is_pending() {
70+
return Ok(());
71+
}
72+
73+
let outdated = self.is_outdated(dur)?;
74+
75+
if !force && !outdated {
7076
return Ok(());
7177
}
7278

@@ -77,8 +83,8 @@ impl AsyncTags {
7783
self.pending.fetch_add(1, Ordering::Relaxed);
7884

7985
rayon_core::spawn(move || {
80-
let notify =
81-
Self::getter(&arc_last).expect("error getting tags");
86+
let notify = Self::getter(&arc_last, outdated)
87+
.expect("error getting tags");
8288

8389
arc_pending.fetch_sub(1, Ordering::Relaxed);
8490

@@ -96,14 +102,16 @@ impl AsyncTags {
96102

97103
fn getter(
98104
arc_last: &Arc<Mutex<Option<(Instant, TagsResult)>>>,
105+
outdated: bool,
99106
) -> Result<bool> {
100107
let tags = sync::get_tags(CWD)?;
101108

102109
let hash = hash(&tags);
103110

104-
if Self::last_hash(arc_last)
105-
.map(|last| last == hash)
106-
.unwrap_or_default()
111+
if !outdated
112+
&& Self::last_hash(arc_last)
113+
.map(|last| last == hash)
114+
.unwrap_or_default()
107115
{
108116
return Ok(false);
109117
}

0 commit comments

Comments
 (0)