summaryrefslogtreecommitdiffstats
path: root/common/menu.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-06-24 14:53:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-06-30 20:23:26 +0200
commit4f02e70d6d04ee949ceee6c1aaec1a2d804fe8a1 (patch)
treeefdd84fcab2edec11713e61ac30961f74966f177 /common/menu.c
parentfa37257ce072c7faac7d0fedbd37a99774cb9267 (diff)
downloadbarebox-4f02e70d6d04ee949ceee6c1aaec1a2d804fe8a1.tar.gz
menu: store repaint state in variable
Instead of calling print_menu_entry multiple times in each case, store the repaint state in a variable and call it once at the end to save a few bytes of binary space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/menu.c')
-rw-r--r--common/menu.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/common/menu.c b/common/menu.c
index cb2a6fe..0f5df2c 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -343,6 +343,9 @@ int menu_show(struct menu *m)
gotoXY(m->selected->num + 1, 3);
do {
+ struct menu_entry *old_selected = m->selected;
+ int repaint = 0;
+
if (m->auto_select >= 0)
ch = KEY_RETURN;
else
@@ -352,24 +355,22 @@ int menu_show(struct menu *m)
switch (ch) {
case KEY_UP:
- print_menu_entry(m, m->selected, 0);
m->selected = list_entry(m->selected->list.prev, struct menu_entry,
list);
if (&(m->selected->list) == &(m->entries)) {
m->selected = list_entry(m->selected->list.prev, struct menu_entry,
list);
}
- print_menu_entry(m, m->selected, 1);
+ repaint = 1;
break;
case KEY_DOWN:
- print_menu_entry(m, m->selected, 0);
m->selected = list_entry(m->selected->list.next, struct menu_entry,
list);
if (&(m->selected->list) == &(m->entries)) {
m->selected = list_entry(m->selected->list.next, struct menu_entry,
list);
}
- print_menu_entry(m, m->selected, 1);
+ repaint = 1;
break;
case ' ':
if (m->selected->type != MENU_ENTRY_BOX)
@@ -377,7 +378,7 @@ int menu_show(struct menu *m)
m->selected->box_state = !m->selected->box_state;
if (m->selected->action)
m->selected->action(m, m->selected);
- print_menu_entry(m, m->selected, 1);
+ repaint = 1;
break;
case KEY_ENTER:
if (ch_previous == KEY_RETURN)
@@ -395,6 +396,12 @@ int menu_show(struct menu *m)
default:
break;
}
+
+ if (repaint) {
+ print_menu_entry(m, old_selected, 0);
+ print_menu_entry(m, m->selected, 1);
+ }
+
ch_previous = ch;
} while(1);