Allocating with capacity
This commit is contained in:
parent
217ce94e1c
commit
21584f4edf
3 changed files with 7 additions and 6 deletions
|
|
@ -35,7 +35,7 @@ fn layout_groups(area: Rect, groups: &[GroupViewState]) -> Vec<Rect> {
|
|||
let line_height = content_height as usize / total_lines;
|
||||
|
||||
let mut current_y = area.y + 1;
|
||||
let mut areas = Vec::new();
|
||||
let mut areas = Vec::with_capacity(groups.len());
|
||||
|
||||
for group in groups {
|
||||
let group_lines = group.monitors.len() + 2;
|
||||
|
|
@ -185,13 +185,14 @@ fn get_formated_line(text: String, color: Color, modifier: Modifier) -> Line<'st
|
|||
}
|
||||
|
||||
fn create_status_line_spans(status_history: &[MonitorStatus]) -> Line<'_> {
|
||||
let mut spans = Vec::new();
|
||||
let recent_status: Vec<_> = status_history
|
||||
.iter()
|
||||
.rev()
|
||||
.take(STATUS_LINE_LENGTH)
|
||||
.collect();
|
||||
|
||||
let mut spans = Vec::with_capacity(recent_status.len());
|
||||
|
||||
for status in recent_status.iter().rev() {
|
||||
let c = get_status_char(status);
|
||||
let color = get_status_color(status);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl DashboardViewState {
|
|||
}
|
||||
|
||||
pub fn from_unified_data(data: UnifiedData) -> Self {
|
||||
let mut groups = Vec::new();
|
||||
let mut groups = Vec::with_capacity(data.groups.len());
|
||||
|
||||
for group in data.groups {
|
||||
groups.push(GroupViewState {
|
||||
|
|
@ -92,7 +92,7 @@ fn get_status_history(heartbeats: &[HeartbeatEntry]) -> Vec<MonitorStatus> {
|
|||
}
|
||||
|
||||
fn add_monitor_view_state(group: UnifiedGroupData) -> Vec<MonitorViewState> {
|
||||
let mut monitors = Vec::new();
|
||||
let mut monitors = Vec::with_capacity(group.monitors.len());
|
||||
|
||||
for monitor in group.monitors {
|
||||
let status_history = get_status_history(&monitor.heartbeats);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue