aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_help.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-17 12:25:40 +0200
committerMax Kellermann <max@duempel.org>2008-09-17 12:25:40 +0200
commit93414ec4a69b58269715ceec18531e3177d66f5f (patch)
treeb6a6a5bfdc8c802bc7490e5cbbc62abcc1f3f53b /src/screen_help.c
parent7384f623975900808c1446cb2979c367565a0656 (diff)
downloadmpd-93414ec4a69b58269715ceec18531e3177d66f5f.tar.gz
mpd-93414ec4a69b58269715ceec18531e3177d66f5f.tar.xz
mpd-93414ec4a69b58269715ceec18531e3177d66f5f.zip
help: converted help_text_rows to a macro
Why bother counting the elements of help_text[] (with sentinel) at runtime, when the compiler can do it at compile time?
Diffstat (limited to '')
-rw-r--r--src/screen_help.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/screen_help.c b/src/screen_help.c
index 363b440cf..05b735ecc 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -139,11 +139,10 @@ static help_text_row_t help_text[] =
{ 0, CMD_LYRICS_UPDATE, N_("Explicitly download lyrics") },
{ 0, CMD_ADD, N_("Save lyrics") },
#endif
- { 0, CMD_NONE, NULL },
- {-1, CMD_NONE, NULL }
};
-static int help_text_rows = -1;
+#define help_text_rows (sizeof(help_text) / sizeof(help_text[0]))
+
static list_window_t *lw = NULL;
@@ -152,14 +151,8 @@ list_callback(unsigned idx, int *highlight, mpd_unused void *data)
{
static char buf[512];
- if (help_text_rows < 0) {
- help_text_rows = 0;
- while (help_text[help_text_rows].highlight != -1)
- help_text_rows++;
- }
-
*highlight = 0;
- if (idx < (unsigned)help_text_rows) {
+ if (idx < help_text_rows) {
*highlight = help_text[idx].highlight > 0;
if (help_text[idx].command == CMD_NONE) {
if (help_text[idx].text)