diff --git a/src/ui/components/monitor_list.rs b/src/ui/components/monitor_list.rs index 24f6081..56a8cfa 100644 --- a/src/ui/components/monitor_list.rs +++ b/src/ui/components/monitor_list.rs @@ -34,7 +34,7 @@ static DOWN_SPAN: Lazy> = static UNKNOWN_SPAN: Lazy> = Lazy::new(|| Span::styled("■", Style::default().fg(Color::Yellow))); -static STATUS_LINE_CACHE: OnceLock>>>> = OnceLock::new(); +static STATUS_LINE_CACHE: OnceLock>>> = OnceLock::new(); pub fn render_monitor_list(main_frame: &mut Frame, area: Rect, state: &mut DashboardViewState) { let available_height = area.height as usize; @@ -251,18 +251,19 @@ fn get_cached_status_line(status_history: &[MonitorStatus]) -> Line<'static> { let cache = STATUS_LINE_CACHE.get_or_init(|| RwLock::new(HashMap::new())); { let read = cache.read().unwrap(); - if let Some(spans) = read.get(&hash) { - return Line::from(spans.iter().map(|&span| span.clone()).collect::>()); + if let Some(line) = read.get(&hash) { + return line.clone(); } } - let spans: Vec<&'static Span<'static>> = status_history + let spans: Vec> = status_history .iter() .rev() .take(STATUS_LINE_LENGTH) - .map(|status| get_status_span(status)) + .map(|status| get_status_span(status).clone()) .collect(); + let new_line = Line::from(spans); let mut write = cache.write().unwrap(); if write.len() > 1000 { let keys_to_remove: Vec<_> = write.keys().take(250).copied().collect(); @@ -271,6 +272,6 @@ fn get_cached_status_line(status_history: &[MonitorStatus]) -> Line<'static> { write.remove(&key); } } - write.insert(hash, spans.clone()); - Line::from(spans.iter().map(|&span| span.clone()).collect::>()) + write.insert(hash, new_line.clone()); + new_line }