refactor: reduce lines of log cloned
Instead of cloning every single line of logs, now we only clone those logs that are visible +- a padding. Containers with hunders or thousands of lines of logs can see a huge reducing in CPU and memory usage
This commit is contained in:
@@ -39,7 +39,8 @@ pub fn draw(
|
||||
}
|
||||
f.render_widget(paragraph, area);
|
||||
} else {
|
||||
let logs = app_data.lock().get_logs();
|
||||
let padding = usize::from(area.height / 5);
|
||||
let logs = app_data.lock().get_logs(area.height, padding);
|
||||
if logs.is_empty() {
|
||||
let mut paragraph = Paragraph::new("no logs found")
|
||||
.block(block)
|
||||
@@ -52,6 +53,7 @@ pub fn draw(
|
||||
let items = List::new(logs)
|
||||
.block(block)
|
||||
.highlight_symbol(RIGHT_ARROW)
|
||||
.scroll_padding(padding)
|
||||
.highlight_style(Style::default().add_modifier(Modifier::BOLD));
|
||||
// This should always return Some, as logs is not empty
|
||||
if let Some(log_state) = app_data.lock().get_log_state() {
|
||||
|
||||
Reference in New Issue
Block a user