From 74415ae71d287d097a7adadea34cb8662735b530 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 2 Apr 2023 14:39:54 +0200 Subject: [PATCH] refactor into array of a `struct` ...instead of having two separate arrays. Signed-off-by: Steffen Jaeckel --- src/command/cmd_ac.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index c986be5e..0cc4a170 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -2083,11 +2083,21 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ } } - gchar* cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/mainwin", "/inputwin" }; - Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac }; + struct + { + gchar* cmd; + Autocomplete completer; + } ac_cmds[] = { + { "/prefs", prefs_ac }, + { "/disco", disco_ac }, + { "/room", room_ac }, + { "/autoping", autoping_ac }, + { "/mainwin", winpos_ac }, + { "/inputwin", winpos_ac }, + }; - for (int i = 0; i < ARRAY_SIZE(cmds); i++) { - result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE, previous); + for (int i = 0; i < ARRAY_SIZE(ac_cmds); i++) { + result = autocomplete_param_with_ac(input, ac_cmds[i].cmd, ac_cmds[i].completer, TRUE, previous); if (result) { return result; }