mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
perf(list): avoid extra allocations when rendering List
(#1244)
When rendering a `List`, each `ListItem` would be cloned. Removing the clone, and replacing `Widget::render` with `WidgetRef::render_ref` saves us allocations caused by the clone of the `Text<'_>` stored inside of `ListItem`. Based on the results of running the "list" benchmark locally; Performance is improved by %1-3 for all `render` benchmarks for `List`.
This commit is contained in:
parent
7ddfbc0010
commit
663486f1e8
1 changed files with 1 additions and 1 deletions
|
@ -108,7 +108,7 @@ impl StatefulWidgetRef for List<'_> {
|
|||
} else {
|
||||
row_area
|
||||
};
|
||||
item.content.clone().render(item_area, buf);
|
||||
item.content.render_ref(item_area, buf);
|
||||
|
||||
for j in 0..item.content.height() {
|
||||
// if the item is selected, we need to display the highlight symbol:
|
||||
|
|
Loading…
Reference in a new issue