mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 10:13:12 +02:00
core: optimize the removal of lines in buffers (a lot faster to clear/close buffers with lot of lines)
The update of variables "buffer_max_length" and "prefix_max_length" in struct t_gui_lines is now delayed and made during the main refresh (in main loop). For a buffer with 50K lines, it is up to 3300 times faster to clear/close it. For a buffer with 4096 lines (default limit), it is up to 120 times faster.
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include "../gui-filter.h"
|
||||
#include "../gui-input.h"
|
||||
#include "../gui-layout.h"
|
||||
#include "../gui-line.h"
|
||||
#include "../gui-history.h"
|
||||
#include "../gui-mouse.h"
|
||||
#include "../gui-nicklist.h"
|
||||
@@ -311,6 +312,35 @@ gui_main_refreshs ()
|
||||
gui_color_buffer_refresh_needed = 0;
|
||||
}
|
||||
|
||||
/* compute max length for prefix/buffer if needed */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
/* compute buffer/prefix max length for own_lines */
|
||||
if (ptr_buffer->own_lines)
|
||||
{
|
||||
if (ptr_buffer->own_lines->buffer_max_length_refresh)
|
||||
{
|
||||
gui_line_compute_buffer_max_length (ptr_buffer,
|
||||
ptr_buffer->own_lines);
|
||||
}
|
||||
if (ptr_buffer->own_lines->prefix_max_length_refresh)
|
||||
gui_line_compute_prefix_max_length (ptr_buffer->own_lines);
|
||||
}
|
||||
|
||||
/* compute buffer/prefix max length for mixed_lines */
|
||||
if (ptr_buffer->mixed_lines)
|
||||
{
|
||||
if (ptr_buffer->mixed_lines->buffer_max_length_refresh)
|
||||
{
|
||||
gui_line_compute_buffer_max_length (ptr_buffer,
|
||||
ptr_buffer->mixed_lines);
|
||||
}
|
||||
if (ptr_buffer->mixed_lines->prefix_max_length_refresh)
|
||||
gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines);
|
||||
}
|
||||
}
|
||||
|
||||
/* refresh window if needed */
|
||||
if (gui_window_refresh_needed)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user