Fix clippy warnings: collapse nested if statements using let-else patterns
This commit is contained in:
parent
a9bf4208ab
commit
764c25846f
@ -269,18 +269,17 @@ impl App {
|
|||||||
// Processes table: sort by column on header click
|
// Processes table: sort by column on header click
|
||||||
if let (Some(mm), Some(p_area)) =
|
if let (Some(mm), Some(p_area)) =
|
||||||
(self.last_metrics.as_ref(), self.last_procs_area)
|
(self.last_metrics.as_ref(), self.last_procs_area)
|
||||||
{
|
&& let Some(new_sort) = processes_handle_mouse(
|
||||||
if let Some(new_sort) = processes_handle_mouse(
|
|
||||||
&mut self.procs_scroll_offset,
|
&mut self.procs_scroll_offset,
|
||||||
&mut self.procs_drag,
|
&mut self.procs_drag,
|
||||||
m,
|
m,
|
||||||
p_area,
|
p_area,
|
||||||
mm.top_processes.len(),
|
mm.top_processes.len(),
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
self.procs_sort_by = new_sort;
|
self.procs_sort_by = new_sort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Event::Resize(_, _) => {}
|
Event::Resize(_, _) => {}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -299,22 +298,21 @@ impl App {
|
|||||||
if self.last_procs_poll.elapsed() >= self.procs_interval {
|
if self.last_procs_poll.elapsed() >= self.procs_interval {
|
||||||
if let Ok(AgentResponse::Processes(procs)) =
|
if let Ok(AgentResponse::Processes(procs)) =
|
||||||
ws.request(AgentRequest::Processes).await
|
ws.request(AgentRequest::Processes).await
|
||||||
|
&& let Some(mm) = self.last_metrics.as_mut()
|
||||||
{
|
{
|
||||||
if let Some(mm) = self.last_metrics.as_mut() {
|
|
||||||
mm.top_processes = procs.top_processes;
|
mm.top_processes = procs.top_processes;
|
||||||
mm.process_count = Some(procs.process_count);
|
mm.process_count = Some(procs.process_count);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.last_procs_poll = Instant::now();
|
self.last_procs_poll = Instant::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only poll disks every 5s
|
// Only poll disks every 5s
|
||||||
if self.last_disks_poll.elapsed() >= self.disks_interval {
|
if self.last_disks_poll.elapsed() >= self.disks_interval {
|
||||||
if let Ok(AgentResponse::Disks(disks)) = ws.request(AgentRequest::Disks).await {
|
if let Ok(AgentResponse::Disks(disks)) = ws.request(AgentRequest::Disks).await
|
||||||
if let Some(mm) = self.last_metrics.as_mut() {
|
&& let Some(mm) = self.last_metrics.as_mut()
|
||||||
|
{
|
||||||
mm.disks = disks;
|
mm.disks = disks;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.last_disks_poll = Instant::now();
|
self.last_disks_poll = Instant::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,19 +71,19 @@ pub(crate) fn parse_args<I: IntoIterator<Item = String>>(args: I) -> Result<Pars
|
|||||||
processes_interval_ms = it.next().and_then(|v| v.parse().ok());
|
processes_interval_ms = it.next().and_then(|v| v.parse().ok());
|
||||||
}
|
}
|
||||||
_ if arg.starts_with("--tls-ca=") => {
|
_ if arg.starts_with("--tls-ca=") => {
|
||||||
if let Some((_, v)) = arg.split_once('=') {
|
if let Some((_, v)) = arg.split_once('=')
|
||||||
if !v.is_empty() {
|
&& !v.is_empty()
|
||||||
|
{
|
||||||
tls_ca = Some(v.to_string());
|
tls_ca = Some(v.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ if arg.starts_with("--profile=") => {
|
_ if arg.starts_with("--profile=") => {
|
||||||
if let Some((_, v)) = arg.split_once('=') {
|
if let Some((_, v)) = arg.split_once('=')
|
||||||
if !v.is_empty() {
|
&& !v.is_empty()
|
||||||
|
{
|
||||||
profile = Some(v.to_string());
|
profile = Some(v.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ if arg.starts_with("--metrics-interval-ms=") => {
|
_ if arg.starts_with("--metrics-interval-ms=") => {
|
||||||
if let Some((_, v)) = arg.split_once('=') {
|
if let Some((_, v)) = arg.split_once('=') {
|
||||||
metrics_interval_ms = v.parse().ok();
|
metrics_interval_ms = v.parse().ok();
|
||||||
@ -416,8 +416,9 @@ fn spawn_demo_agent(port: u16) -> Result<DemoGuard, Box<dyn std::error::Error>>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn find_agent_executable() -> std::path::PathBuf {
|
fn find_agent_executable() -> std::path::PathBuf {
|
||||||
if let Ok(exe) = std::env::current_exe() {
|
if let Ok(exe) = std::env::current_exe()
|
||||||
if let Some(parent) = exe.parent() {
|
&& let Some(parent) = exe.parent()
|
||||||
|
{
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let name = "socktop_agent.exe";
|
let name = "socktop_agent.exe";
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@ -427,6 +428,5 @@ fn find_agent_executable() -> std::path::PathBuf {
|
|||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
std::path::PathBuf::from("socktop_agent")
|
std::path::PathBuf::from("socktop_agent")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -180,8 +180,9 @@ pub fn per_core_handle_scrollbar_mouse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MouseEventKind::Drag(MouseButton::Left) => {
|
MouseEventKind::Drag(MouseButton::Left) => {
|
||||||
if let Some(mut d) = drag.take() {
|
if let Some(mut d) = drag.take()
|
||||||
if d.active {
|
&& d.active
|
||||||
|
{
|
||||||
let dy = (mouse.row as i32) - (d.start_y as i32);
|
let dy = (mouse.row as i32) - (d.start_y as i32);
|
||||||
let new_top = (d.start_top as i32 + dy)
|
let new_top = (d.start_top as i32 + dy)
|
||||||
.clamp(0, (track.saturating_sub(thumb_len)) as i32)
|
.clamp(0, (track.saturating_sub(thumb_len)) as i32)
|
||||||
@ -203,7 +204,6 @@ pub fn per_core_handle_scrollbar_mouse(
|
|||||||
*drag = Some(d);
|
*drag = Some(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
MouseEventKind::Up(MouseButton::Left) => {
|
MouseEventKind::Up(MouseButton::Left) => {
|
||||||
// End drag
|
// End drag
|
||||||
*drag = None;
|
*drag = None;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user