diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-05-11 01:32:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 01:32:39 -0400 |
commit | 7b5685bf446e6e80c15d9629810788d670ec4684 (patch) | |
tree | 72dd21dca7885c7c19941cb63ddd3a2006c596d5 | |
parent | 95f90dd266303ce1934b0f1c7292a06884678c05 (diff) |
refactor: remove redundant empty checks in graphs
Now that the fix for empty data is patched in tui, these checks are
redundant.
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | Cargo.lock | 18 | ||||
-rw-r--r-- | src/canvas/widgets/cpu_graph.rs | 2 | ||||
-rw-r--r-- | src/canvas/widgets/mem_graph.rs | 50 | ||||
-rw-r--r-- | src/canvas/widgets/network_graph.rs | 8 |
5 files changed, 36 insertions, 44 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 19eaf794..1053f13c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - TODO: ~~Moving down the CPU list will show only the corresponding graph.~~ +## [0.4.2] - Unreleased + ### Changes - Automatically hide time axis labels if the widget gets too small. @@ -136,7 +136,7 @@ dependencies = [ "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "sysinfo 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tui 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tui 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "typed-builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -451,7 +451,7 @@ dependencies = [ "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", "pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-hack 0.5.15 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-nested 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -888,15 +888,15 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pin-project-internal 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-internal 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pin-project-internal" -version = "0.4.15" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1195,7 +1195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tui" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1417,8 +1417,8 @@ dependencies = [ "checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" "checksum parking_lot 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" "checksum parking_lot_core 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -"checksum pin-project 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3c50dab4a05419117fe00216df4731e387ae616cd2a5f5dda1d8b02d863ac63d" -"checksum pin-project-internal 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "6c27e5ac1d4c76777afd4d47b8fe9c602b44bcf6f999d34e300bba5560c9837b" +"checksum pin-project 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "81d480cb4e89522ccda96d0eed9af94180b7a5f93fb28f66e1fd7d68431663d1" +"checksum pin-project-internal 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "a82996f11efccb19b685b14b5df818de31c1edcee3daa256ab5775dd98e72feb" "checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" "checksum platforms 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e" "checksum predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" @@ -1456,7 +1456,7 @@ dependencies = [ "checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" "checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" "checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" -"checksum tui 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8b1825bf17ac96464ae6f6a590358a961cb57ee81d03093c50abf5830e36df7a" +"checksum tui 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89e8ecff008935939a4cf834c6e96e6cfb60f65f7d2e009027125f4df492a8d6" "checksum typed-builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "78cea224ddd4282dfc40d1edabbd0c020a12e946e3a48e2c2b8f6ff167ad29fe" "checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" diff --git a/src/canvas/widgets/cpu_graph.rs b/src/canvas/widgets/cpu_graph.rs index 07fb711c..232e8a72 100644 --- a/src/canvas/widgets/cpu_graph.rs +++ b/src/canvas/widgets/cpu_graph.rs @@ -148,7 +148,7 @@ impl CpuGraphWidget for Painter { .enumerate() .rev() .filter_map(|(itx, (cpu, cpu_show_vec))| { - if *cpu_show_vec && !cpu.cpu_data.is_empty() { + if *cpu_show_vec { Some( Dataset::default() .marker(if use_dot { diff --git a/src/canvas/widgets/mem_graph.rs b/src/canvas/widgets/mem_graph.rs index 6dd81b75..40f711d3 100644 --- a/src/canvas/widgets/mem_graph.rs +++ b/src/canvas/widgets/mem_graph.rs @@ -63,33 +63,31 @@ impl MemGraphWidget for Painter { let mut mem_canvas_vec: Vec<Dataset<'_>> = vec![]; - if !mem_data.is_empty() { - mem_canvas_vec.push( - Dataset::default() - .name(&app_state.canvas_data.mem_label) - .marker(if app_state.app_config_fields.use_dot { - Marker::Dot - } else { - Marker::Braille - }) - .style(self.colours.ram_style) - .data(&mem_data).graph_type(tui::widgets::GraphType::Line), - ); - } + mem_canvas_vec.push( + Dataset::default() + .name(&app_state.canvas_data.mem_label) + .marker(if app_state.app_config_fields.use_dot { + Marker::Dot + } else { + Marker::Braille + }) + .style(self.colours.ram_style) + .data(&mem_data) + .graph_type(tui::widgets::GraphType::Line), + ); - if !swap_data.is_empty() { - mem_canvas_vec.push( - Dataset::default() - .name(&app_state.canvas_data.swap_label) - .marker(if app_state.app_config_fields.use_dot { - Marker::Dot - } else { - Marker::Braille - }) - .style(self.colours.swap_style) - .data(&swap_data) .graph_type(tui::widgets::GraphType::Line), - ); - } + mem_canvas_vec.push( + Dataset::default() + .name(&app_state.canvas_data.swap_label) + .marker(if app_state.app_config_fields.use_dot { + Marker::Dot + } else { + Marker::Braille + }) + .style(self.colours.swap_style) + .data(&swap_data) + .graph_type(tui::widgets::GraphType::Line), + ); let title = if app_state.is_expanded { const TITLE_BASE: &str = " Memory ── Esc to go back "; diff --git a/src/canvas/widgets/network_graph.rs b/src/canvas/widgets/network_graph.rs index 9fab03c1..316bd8e6 100644 --- a/src/canvas/widgets/network_graph.rs +++ b/src/canvas/widgets/network_graph.rs @@ -132,7 +132,6 @@ impl NetworkGraphWidget for Painter { let dataset = if app_state.app_config_fields.use_old_network_legend && !hide_legend { let mut ret_val = vec![]; - if !network_data_rx.is_empty() { ret_val.push( Dataset::default() .name(format!("RX: {:7}", app_state.canvas_data.rx_display)) @@ -144,9 +143,7 @@ impl NetworkGraphWidget for Painter { .style(self.colours.rx_style) .data(&network_data_rx).graph_type(tui::widgets::GraphType::Line), ); - } - if !network_data_tx.is_empty() { ret_val.push( Dataset::default() .name(format!("TX: {:7}", app_state.canvas_data.tx_display)) @@ -166,7 +163,6 @@ impl NetworkGraphWidget for Painter { )) .style(self.colours.total_rx_style), ); - } ret_val.push( Dataset::default() @@ -181,7 +177,6 @@ impl NetworkGraphWidget for Painter { } else { let mut ret_val = vec![]; - if !network_data_rx.is_empty() { ret_val.push( Dataset::default() .name(&app_state.canvas_data.rx_display) @@ -193,9 +188,7 @@ impl NetworkGraphWidget for Painter { .style(self.colours.rx_style) .data(&network_data_rx).graph_type(tui::widgets::GraphType::Line), ); - } - if !network_data_tx.is_empty() { ret_val.push( Dataset::default() .name(&app_state.canvas_data.tx_display) @@ -207,7 +200,6 @@ impl NetworkGraphWidget for Painter { .style(self.colours.tx_style) .data(&network_data_tx).graph_type(tui::widgets::GraphType::Line), ); - } ret_val }; |