summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7384f62)
raw | patch | inline | side by side (parent: 7384f62)
author | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 10:25:40 +0000 (12:25 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 10:25:40 +0000 (12:25 +0200) |
Why bother counting the elements of help_text[] (with sentinel) at
runtime, when the compiler can do it at compile time?
runtime, when the compiler can do it at compile time?
src/screen_help.c | patch | blob | history |
diff --git a/src/screen_help.c b/src/screen_help.c
index 363b440cf8f804bb05b7a3eb94331f747b3b0698..05b735eccc2c6c33f4ba85865d8479da1c3accf4 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
{ 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;
{
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)