From 41b34a45ec4879ff45c3a775bc0f8e4f96ded265 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 7 Nov 2019 16:42:14 -0500 Subject: don't recalculate total matches unless we have added more frames --- src/cmd/play.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cmd/play.rs b/src/cmd/play.rs index 756c907..ebf1d2b 100644 --- a/src/cmd/play.rs +++ b/src/cmd/play.rs @@ -135,6 +135,7 @@ impl Ttyrec { struct SearchState { query: regex::bytes::Regex, count: usize, + total_frame_count: usize, idx: Option, } @@ -263,7 +264,10 @@ impl Player { if let Some(idx) = &mut state.idx { state.idx = Some(*idx + 1); } else { - state.count = self.ttyrec.count_matches_from(0, &state.query); + if state.total_frame_count != self.ttyrec.len() { + state.count = + self.ttyrec.count_matches_from(0, &state.query); + } state.idx = Some( state.count - self @@ -297,7 +301,10 @@ impl Player { if let Some(idx) = &mut state.idx { state.idx = Some(*idx - 1); } else { - state.count = self.ttyrec.count_matches_from(0, &state.query); + if state.total_frame_count != self.ttyrec.len() { + state.count = + self.ttyrec.count_matches_from(0, &state.query); + } state.idx = Some( state.count - self @@ -356,6 +363,7 @@ impl Player { self.search_state = Some(SearchState { query: re, count, + total_frame_count: self.ttyrec.len(), idx: None, }); self.next_match(); -- cgit v1.2.3-54-g00ecf