optimizations
This commit is contained in:
parent
64f5115d54
commit
99d4b94e5c
6 changed files with 54 additions and 48 deletions
|
|
@ -137,11 +137,10 @@ fn render_monitor_table(
|
|||
|
||||
let header = Row::new(header_cells).style(title_style()).height(1);
|
||||
|
||||
let rows: Vec<Row> = monitors
|
||||
.iter()
|
||||
.take(items_to_show)
|
||||
.map(|monitor| create_monitor_item(monitor))
|
||||
.collect();
|
||||
let mut rows: Vec<Row> = Vec::with_capacity(items_to_show);
|
||||
for monitor in monitors.iter().take(items_to_show) {
|
||||
rows.push(create_monitor_item(monitor));
|
||||
}
|
||||
|
||||
let widths = vec![
|
||||
Constraint::Length(3),
|
||||
|
|
@ -256,17 +255,20 @@ fn get_cached_status_line(status_history: &[MonitorStatus]) -> Line<'static> {
|
|||
}
|
||||
}
|
||||
|
||||
let spans: Vec<Span<'static>> = status_history
|
||||
.iter()
|
||||
.rev()
|
||||
.take(STATUS_LINE_LENGTH)
|
||||
.map(|status| get_status_span(status).clone())
|
||||
.collect();
|
||||
let mut spans: Vec<Span<'static>> = Vec::with_capacity(STATUS_LINE_LENGTH);
|
||||
spans.extend(
|
||||
status_history
|
||||
.iter()
|
||||
.rev()
|
||||
.take(STATUS_LINE_LENGTH)
|
||||
.map(|status| get_status_span(status).clone()),
|
||||
);
|
||||
|
||||
let new_line = Line::from(spans);
|
||||
let mut write = cache.write().unwrap();
|
||||
if write.len() > 1000 {
|
||||
let keys_to_remove: Vec<_> = write.keys().take(250).copied().collect();
|
||||
let mut keys_to_remove: Vec<u64> = Vec::with_capacity(250);
|
||||
keys_to_remove.extend(write.keys().take(250).copied());
|
||||
|
||||
for key in keys_to_remove {
|
||||
write.remove(&key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue