From 696e9e087222f13e8a39b3912ca6cb3da7e1df5c Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Fri, 15 Aug 2025 11:13:00 +0000 Subject: [PATCH] refactor: redraw get_clear() use a swap --- src/docker_data/mod.rs | 3 +-- src/ui/redraw.rs | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/docker_data/mod.rs b/src/docker_data/mod.rs index 7aae791..a42e5d4 100644 --- a/src/docker_data/mod.rs +++ b/src/docker_data/mod.rs @@ -145,7 +145,6 @@ impl DockerData { ) .take(1); - // some err here while let Some(Ok(stats)) = stream.next().await { // Memory stats are only collected if the container is alive - is this the behaviour we want? @@ -169,7 +168,7 @@ impl DockerData { (None, None) }; - // TODO Is hardcoded eth0 a good idea here? + // TODO is hardcoded eth0 a good idea here? - Could use first() instead? let (rx, tx) = stats.networks.as_ref().map_or((0, 0), |i| { i.get("eth0").map_or((0, 0), |x| { ( diff --git a/src/ui/redraw.rs b/src/ui/redraw.rs index 0647853..7593643 100644 --- a/src/ui/redraw.rs +++ b/src/ui/redraw.rs @@ -19,12 +19,7 @@ impl Rerender { } pub fn get_clear(&self) -> bool { - if self.clear.load(Ordering::SeqCst) { - self.clear.store(false, Ordering::SeqCst); - true - } else { - false - } + self.clear.swap(false, Ordering::SeqCst) } pub fn set_clear(&self) {