From baa598276c4aba57dc9e91ffae46b1477c0d0fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 22 Feb 2019 21:33:39 +0100 Subject: fset: fix slow refresh of fset buffer during /reload (closes #1313) --- src/plugins/fset/fset-option.c | 31 ++++++++++++++++++++++++++----- src/plugins/fset/fset-option.h | 2 ++ 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c index c192182c3..895b633e2 100644 --- a/src/plugins/fset/fset-option.c +++ b/src/plugins/fset/fset-option.c @@ -1491,9 +1491,20 @@ fset_option_config_timer_cb (const void *pointer, (void) data; (void) remaining_calls; - weechat_hashtable_map (fset_option_timer_options_changed, - &fset_option_timer_option_changed_cb, - NULL); + if (weechat_hashtable_get_integer ( + fset_option_timer_options_changed, + "items_count") >= FSET_OPTION_TIMER_MAX_OPTIONS_CHANGED) + { + fset_option_get_options (); + fset_buffer_refresh (1); + } + else + { + weechat_hashtable_map (fset_option_timer_options_changed, + &fset_option_timer_option_changed_cb, + NULL); + } + weechat_hashtable_remove_all (fset_option_timer_options_changed); fset_option_timer_hook = NULL; @@ -1527,8 +1538,18 @@ fset_option_config_cb (const void *pointer, if (ptr_info && (strcmp (ptr_info, "1") == 0)) return WEECHAT_RC_OK; - weechat_hashtable_set (fset_option_timer_options_changed, - option, NULL); + /* + * we limit the number of options to display with the timer; for example + * on /reload, many options are changed, so we'll get all options and + * display them, instead of change them one by one, which is very slow + */ + if (weechat_hashtable_get_integer ( + fset_option_timer_options_changed, + "items_count") < FSET_OPTION_TIMER_MAX_OPTIONS_CHANGED) + { + weechat_hashtable_set (fset_option_timer_options_changed, + option, NULL); + } if (!fset_option_timer_hook) { diff --git a/src/plugins/fset/fset-option.h b/src/plugins/fset/fset-option.h index 34e607486..3800dd437 100644 --- a/src/plugins/fset/fset-option.h +++ b/src/plugins/fset/fset-option.h @@ -22,6 +22,8 @@ #define FSET_OPTION_VALUE_NULL "null" +#define FSET_OPTION_TIMER_MAX_OPTIONS_CHANGED 32 + enum t_fset_option_type { FSET_OPTION_TYPE_BOOLEAN = 0, -- cgit v1.2.3