From 6714d6fc820e56ea53cd67e604a0928e7a974e84 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 10 Aug 2013 17:18:12 +0200 Subject: 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. --- src/gui/gui-buffer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/gui/gui-buffer.c') diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 2f8352eb4..5b33a8c58 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -1013,7 +1013,7 @@ gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name) strdup (short_name) : NULL; if (buffer->mixed_lines) - gui_line_compute_buffer_max_length (buffer, buffer->mixed_lines); + buffer->mixed_lines->buffer_max_length_refresh = 1; gui_buffer_ask_chat_refresh (buffer, 1); hook_signal_send ("buffer_renamed", @@ -2741,9 +2741,8 @@ gui_buffer_unmerge (struct t_gui_buffer *buffer, int number) if (ptr_new_active_buffer) { - gui_line_compute_prefix_max_length (ptr_new_active_buffer->mixed_lines); - gui_line_compute_buffer_max_length (ptr_new_active_buffer, - ptr_new_active_buffer->mixed_lines); + ptr_new_active_buffer->mixed_lines->prefix_max_length_refresh = 1; + ptr_new_active_buffer->mixed_lines->buffer_max_length_refresh = 1; } gui_window_ask_refresh (1); -- cgit v1.2.3