String optimizations
This commit is contained in:
parent
6109785e63
commit
3929a4a277
2 changed files with 13 additions and 13 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Cow;
|
||||
use std::cmp::min;
|
||||
|
||||
use crate::i18n::t;
|
||||
|
|
@ -52,12 +53,7 @@ pub fn render_monitor_list(main_frame: &mut Frame, area: Rect, state: &mut Dashb
|
|||
height: visible_height as u16,
|
||||
};
|
||||
|
||||
render_group(
|
||||
main_frame,
|
||||
group_area,
|
||||
group,
|
||||
half > rendered_height ,
|
||||
);
|
||||
render_group(main_frame, group_area, group, half > rendered_height);
|
||||
|
||||
current_y += visible_height;
|
||||
rendered_height += visible_height;
|
||||
|
|
@ -178,10 +174,14 @@ fn create_monitor_item(monitor: &MonitorViewState) -> Row<'_> {
|
|||
let status_icon = get_status_emoji(&monitor.status);
|
||||
let status_color = get_status_color(&monitor.status);
|
||||
|
||||
let display_name: String = if monitor.name.len() > MAX_NAME_LENGTH {
|
||||
format!("{:.width$}...", &monitor.name, width = MAX_NAME_LENGTH - 3)
|
||||
let display_name: Cow<str> = if monitor.name.len() > MAX_NAME_LENGTH {
|
||||
Cow::Owned(format!(
|
||||
"{:.width$}...",
|
||||
monitor.name,
|
||||
width = MAX_NAME_LENGTH - 3
|
||||
))
|
||||
} else {
|
||||
monitor.name.clone()
|
||||
Cow::Borrowed(&monitor.name)
|
||||
};
|
||||
|
||||
let response_text = format!("{:>7}ms", monitor.response_time);
|
||||
|
|
@ -191,7 +191,7 @@ fn create_monitor_item(monitor: &MonitorViewState) -> Row<'_> {
|
|||
|
||||
Row::new(vec![
|
||||
get_formated_line(format!("{} ", status_icon), status_color, Modifier::empty()),
|
||||
get_formated_line(display_name, Color::White, Modifier::empty()),
|
||||
get_formated_line(display_name.to_string(), Color::White, Modifier::empty()),
|
||||
get_formated_line(response_text, Color::Cyan, Modifier::empty()),
|
||||
get_formated_line(uptime_text, Color::Magenta, Modifier::empty()),
|
||||
status_line_spans,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue