refactor: clear cache in Graph::update

This commit is contained in:
electria 2026-08-16 10:18:24 -07:00
commit 865fecd694
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
2 changed files with 2 additions and 4 deletions

View file

@ -30,6 +30,8 @@ impl Graph {
if self.timeline.len() > 500 {
self.timeline.pop_front();
}
self.cache.clear();
}
}

View file

@ -48,15 +48,12 @@ impl State {
match message {
Message::Info(snapshot) => {
self.total_cpu_graph.update(snapshot.cpu_total);
self.total_cpu_graph.cache.clear();
self.memory_graph
.update(snapshot.memory as f32 / snapshot.memory_total as f32 * 100.);
self.memory_graph.cache.clear();
self.swap_graph
.update(snapshot.swap as f32 / snapshot.swap_total as f32 * 100.);
self.swap_graph.cache.clear();
if self.cpu_graphs.len() != snapshot.cpus.len() {
self.cpu_graphs = snapshot
@ -68,7 +65,6 @@ impl State {
for (graph, value) in self.cpu_graphs.iter_mut().zip(snapshot.cpus.into_iter())
{
graph.update(value);
graph.cache.clear();
}
}
}