1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 17:53:13 +02:00

core: fix too many sorts of hotlist when buffers are moved (issue #2097)

A performance issue was happening when buffers are moved to another position
and when the hotlist contains a lot of buffers: each time a signal
"buffer_moved" is sent, the hotlist is sorted again.

This fix delays the resort of hotlist after all the moves are done using a
timer with a very small delay (one millisecond).
This commit is contained in:
Sébastien Helleu
2024-11-03 23:35:13 +01:00
parent 1fc8c551d8
commit 74cc16ef07
2 changed files with 28 additions and 1 deletions
+1
View File
@@ -27,6 +27,7 @@
- exec: fix unexpected execution of command with `/exec -o` when the command starts with two command chars ([#2199](https://github.com/weechat/weechat/issues/2199))
- relay/api: fix empty nicklist in remote buffers after connection or reconnection
- relay/api: reply HTTP 400 (Bad Request) when the body received is not a dict in websocket data
- core: fix too many sorts of hotlist when buffers are moved ([#2097](https://github.com/weechat/weechat/issues/2097))
- core: always send the signal "buffer_switch", even when the buffer is opening ([#2198](https://github.com/weechat/weechat/issues/2198))
- core: reload all plugins with command `/plugin reload *`
- relay, xfer: fix letters with actions displayed on top of buffer
+27 -1
View File
@@ -71,6 +71,7 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
};
struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL;
struct t_hook *gui_bar_item_timer = NULL;
struct t_hook *gui_bar_item_timer_hotlist_resort = NULL;
/*
@@ -2275,6 +2276,25 @@ gui_bar_item_timer_cb (const void *pointer, void *data, int remaining_calls)
return WEECHAT_RC_OK;
}
/*
* Timer callback for resorting hotlist.
*/
int
gui_bar_item_timer_hotlist_resort_cb (const void *pointer, void *data,
int remaining_calls)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) remaining_calls;
gui_hotlist_resort ();
gui_bar_item_timer_hotlist_resort = NULL;
return WEECHAT_RC_OK;
}
/*
* Callback when a signal is received: rebuilds an item.
*/
@@ -2298,7 +2318,13 @@ gui_bar_item_signal_cb (const void *pointer, void *data,
if ((strcmp (item, "hotlist") == 0)
&& (strcmp (signal, "hotlist_changed") != 0))
{
gui_hotlist_resort ();
if (!gui_bar_item_timer_hotlist_resort)
{
gui_bar_item_timer_hotlist_resort = hook_timer (
NULL,
1, 0, 1,
&gui_bar_item_timer_hotlist_resort_cb, NULL, NULL);
}
}
gui_bar_item_update (item);
}