remove list iterators to save space

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-24 16:25:10 +01:00
parent 2e71383172
commit 2322a12693

View file

@ -67,24 +67,16 @@ grub_putchar (int c)
grub_uint32_t code; grub_uint32_t code;
grub_ssize_t ret; grub_ssize_t ret;
auto int do_putcode (grub_list_t item);
int do_putcode (grub_list_t item)
{
struct grub_term_output *term = (struct grub_term_output *) item;
if (grub_term_is_active (term))
grub_putcode (code, term);
return 0;
}
buf[size++] = c; buf[size++] = c;
ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0); ret = grub_utf8_to_ucs4 (&code, 1, buf, size, 0);
if (ret != 0) if (ret != 0)
{ {
struct grub_term_output *term;
size = 0; size = 0;
grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), do_putcode); for (term = grub_term_outputs; term; term = term->next)
if (grub_term_is_active (term))
grub_putcode (code, term);
} }
if (ret == '\n' && grub_newline_hook) if (ret == '\n' && grub_newline_hook)
grub_newline_hook (); grub_newline_hook ();
@ -114,62 +106,39 @@ grub_getkeystatus (void)
void void
grub_cls (void) grub_cls (void)
{ {
auto int hook (grub_list_t item); struct grub_term_output *term;
int hook (grub_list_t item)
{ for (term = grub_term_outputs; term; term = term->next)
struct grub_term_output *term = (struct grub_term_output *) item; {
if (! grub_term_is_active (term))
continue;
if (! grub_term_is_active (term)) if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
return 0; {
grub_putcode ('\n', term);
if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug"))) grub_refresh ();
{ }
grub_putcode ('\n', term); else
grub_refresh (); (term->cls) ();
} }
else
(term->cls) ();
return 0;
}
grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook);
} }
void void
grub_setcolorstate (grub_term_color_state state) grub_setcolorstate (grub_term_color_state state)
{ {
auto int hook (grub_list_t item); struct grub_term_output *term;
int hook (grub_list_t item)
{ for (term = grub_term_outputs; term; term = term->next)
struct grub_term_output *term = (struct grub_term_output *) item; if (grub_term_is_active (term))
grub_term_setcolorstate (term, state);
if (! grub_term_is_active (term))
return 0;
grub_term_setcolorstate (term, state);
return 0;
}
grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook);
} }
void void
grub_refresh (void) grub_refresh (void)
{ {
auto int hook (grub_list_t item); struct grub_term_output *term;
int hook (grub_list_t item)
{
struct grub_term_output *term = (struct grub_term_output *) item;
if (!grub_term_is_active (term)) for (term = grub_term_outputs; term; term = term->next)
return 0; if (grub_term_is_active (term))
grub_term_refresh (term);
grub_term_refresh (term);
return 0;
}
grub_list_iterate (GRUB_AS_LIST (grub_term_outputs), hook);
} }