diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-11-09 22:47:15 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-09 22:47:15 +0000 |
commit | edf5a70e276b5440ebb60713cf5db936eae09498 (patch) | |
tree | 335de901da47468f59c6f2b47954e2b83b6df9e7 | |
parent | c83216ad891339c140358ee342e883d14b3d7158 (diff) |
Replaced the common for(i = 0; i < NB_SCREENS; i++) loop with a macro that just expands to i = 0; instead of the for() loop if NB_SCREENS == 1. Reduces binary size on platforms with only one screen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7805 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/list.c | 24 | ||||
-rw-r--r-- | apps/gui/select.c | 2 | ||||
-rw-r--r-- | apps/gui/splash.c | 2 | ||||
-rw-r--r-- | apps/gui/statusbar.c | 4 | ||||
-rw-r--r-- | apps/screen_access.c | 2 | ||||
-rw-r--r-- | apps/screen_access.h | 6 | ||||
-rw-r--r-- | apps/tree.c | 26 |
7 files changed, 36 insertions, 30 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c index cd5af40a98..c0b6ce24f9 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -379,7 +379,7 @@ void gui_synclist_init( ) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) { gui_list_init(&(lists->gui_list[i]), callback_get_item_icon, @@ -392,7 +392,7 @@ void gui_synclist_init( void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) { gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); } @@ -401,28 +401,28 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items) void gui_synclist_draw(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_draw(&(lists->gui_list[i])); } void gui_synclist_select_item(struct gui_synclist * lists, int item_number) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_select_item(&(lists->gui_list[i]), item_number); } void gui_synclist_select_next(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_select_next(&(lists->gui_list[i])); } void gui_synclist_select_previous(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_select_previous(&(lists->gui_list[i])); } @@ -430,7 +430,7 @@ void gui_synclist_select_next_page(struct gui_synclist * lists, enum screen_type screen) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_select_next_page(&(lists->gui_list[i]), screens[screen].nb_lines); } @@ -439,7 +439,7 @@ void gui_synclist_select_previous_page(struct gui_synclist * lists, enum screen_type screen) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_select_previous_page(&(lists->gui_list[i]), screens[screen].nb_lines); } @@ -447,28 +447,28 @@ void gui_synclist_select_previous_page(struct gui_synclist * lists, void gui_synclist_add_item(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_add_item(&(lists->gui_list[i])); } void gui_synclist_del_item(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_del_item(&(lists->gui_list[i])); } void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_limit_scroll(&(lists->gui_list[i]), scroll); } void gui_synclist_flash(struct gui_synclist * lists) { int i; - for(i = 0;i < NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_list_flash(&(lists->gui_list[i])); } diff --git a/apps/gui/select.c b/apps/gui/select.c index 95a3083714..5cde812a2f 100644 --- a/apps/gui/select.c +++ b/apps/gui/select.c @@ -128,7 +128,7 @@ void gui_select_draw(struct gui_select * select, struct screen * display) void gui_syncselect_draw(struct gui_select * select) { int i; - for(i=0;i<NB_SCREENS;i++) + FOR_NB_SCREENS(i) gui_select_draw(select, &(screens[i])); } diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 385d75a2cf..fc15294211 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -207,7 +207,7 @@ void gui_syncsplash(int ticks, bool center, const char *fmt, ...) va_list ap; int i; va_start( ap, fmt ); - for(i=0;i<NB_SCREENS;i++) + FOR_NB_SCREENS(i) internal_splash(&(screens[i]), center, fmt, ap); va_end( ap ); diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index 0a506b0c28..efc74d50af 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -500,7 +500,7 @@ void gui_statusbar_time(struct screen * display, int hour, int minute) void gui_syncstatusbar_init(struct gui_syncstatusbar * bars) { int i; - for(i = 0;i < NB_SCREENS;i++) { + FOR_NB_SCREENS(i) { gui_statusbar_init( &(bars->statusbars[i]) ); gui_statusbar_set_screen( &(bars->statusbars[i]), &(screens[i]) ); } @@ -510,7 +510,7 @@ void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, bool force_redraw) { int i; - for(i = 0;i < NB_SCREENS;i++) { + FOR_NB_SCREENS(i) { gui_statusbar_draw( &(bars->statusbars[i]), force_redraw ); } } diff --git a/apps/screen_access.c b/apps/screen_access.c index 5dde0cb8ae..1d2535fb66 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -153,7 +153,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type) void screen_access_init(void) { int i; - for(i=0;i<NB_SCREENS;i++) + FOR_NB_SCREENS(i) screen_init(&screens[i], i); } diff --git a/apps/screen_access.h b/apps/screen_access.h index 5b30cb0aa7..c167708fbf 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h @@ -36,6 +36,12 @@ enum screen_type { #define NB_SCREENS 1 #endif +#if NB_SCREENS == 1 +#define FOR_NB_SCREENS(i) i = 0; +#else +#define FOR_NB_SCREENS(i) for(i = 0; i < NB_SCREENS; i++) +#endif + #ifdef HAVE_LCD_CHARCELLS #define MAX_LINES_ON_SCREEN 2 #endif diff --git a/apps/tree.c b/apps/tree.c index 0e91a58944..02ba9c79fc 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -195,10 +195,10 @@ bool check_rockboxdir(void) if(!dir) { int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) screens[i].clear_display(); gui_syncsplash(HZ*2, true, str(LANG_NO_ROCKBOX_DIR)); - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) screens[i].clear_display(); gui_syncsplash(HZ*2, true, str(LANG_INSTALLATION_INCOMPLETE)); return false; @@ -219,7 +219,7 @@ void browse_root(void) #ifdef HAVE_LCD_CHARCELLS int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) screens[i].double_height(false); #endif #ifdef HAS_BUTTONBAR @@ -320,7 +320,7 @@ static int update_dir(void) { /* dir full */ int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); #ifdef HAVE_LCD_CHARCELLS @@ -332,7 +332,7 @@ static int update_dir(void) gui_textarea_update(&screens[i]); } sleep(HZ*2); - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) gui_textarea_clear(&screens[i]); } } @@ -560,7 +560,7 @@ static bool dirbrowse(void) bool stop = false; unsigned int button; int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); screens[i].puts(0,0,str(LANG_BOOT_CHANGED)); @@ -695,7 +695,7 @@ static bool dirbrowse(void) if (*tc.dirfilter < NUM_FILTER_MODES) { int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) screens[i].stop_scroll(); if (main_menu()) reload_dir = true; @@ -878,7 +878,7 @@ static bool dirbrowse(void) if (start_wps && audio_status() ) { int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) screens[i].stop_scroll(); if (wps_show() == SYS_USB_CONNECTED) reload_dir = true; @@ -1077,7 +1077,7 @@ static bool add_dir(char* dirname, int len, int fd) plsize++; snprintf(buf, sizeof buf, "%d", plsize); #ifdef HAVE_LCD_BITMAP - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); screens[i].puts(0,4,buf); @@ -1094,7 +1094,7 @@ static bool add_dir(char* dirname, int len, int fd) x=9; } } - for(i = 0;i < NB_SCREENS;++i) { + FOR_NB_SCREENS(i) { screens[i].puts(x,0,buf); gui_textarea_update(&screens[i]); } @@ -1119,7 +1119,7 @@ bool create_playlist(void) snprintf(filename, sizeof filename, "%s.m3u", tc.currdir[1] ? tc.currdir : "/root"); - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); screens[i].puts(0,0,str(LANG_CREATING)); @@ -1357,7 +1357,7 @@ void tree_restore(void) { /* Print "Scanning disk..." to the display. */ int i; - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { screens[i].putsxy((LCD_WIDTH/2) - ((strlen(str(LANG_DIRCACHE_BUILDING)) * @@ -1370,7 +1370,7 @@ void tree_restore(void) dircache_build(global_settings.dircache_size); /* Clean the text when we are done. */ - for(i = 0;i < NB_SCREENS;++i) + FOR_NB_SCREENS(i) { gui_textarea_clear(&screens[i]); } |