From e9d5127eaaa0053467da0e5fc46cf6a5cd7637e0 Mon Sep 17 00:00:00 2001 From: Robert Hak Date: Thu, 12 Sep 2002 09:11:59 +0000 Subject: efficiency improvement git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2265 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 71 +++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 38 deletions(-) (limited to 'apps') diff --git a/apps/playlist.c b/apps/playlist.c index 8121b3b85a..d9c56b62b1 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -301,9 +301,9 @@ void add_indices_to_playlist(void) int nread; int fd = -1; int i = 0; - int store_index = 0; int count = 0; int next_tick = current_tick + HZ; + bool store_index = true; unsigned char *p = playlist_buffer; char line[16]; @@ -314,7 +314,7 @@ void add_indices_to_playlist(void) return; /* failure */ } - store_index = 1; + store_index = true; while(1) { @@ -334,47 +334,42 @@ void add_indices_to_playlist(void) /* Are we on a new line? */ if((*p == '\n') || (*p == '\r')) { - store_index = 1; + store_index = true; } - else if(!playlist.in_ram && (*p == '#') && store_index) - { - /* If the first character on a new line is a hash - sign, we treat it as a comment. So called winamp - style playlist. - This applies only to playlist files, of course */ - store_index = 0; - } else if(store_index) { - - /* Store a new entry */ - playlist.indices[ playlist.amount ] = i+count; - playlist.amount++; - if ( playlist.amount >= MAX_PLAYLIST_SIZE ) { - if(!playlist.in_ram) - close(fd); - - lcd_clear_display(); - lcd_puts(0,0,"Playlist"); - lcd_puts(0,1,"buffer full"); - lcd_update(); - sleep(HZ*2); - lcd_clear_display(); - - return; - } - - store_index = 0; - /* Update the screen if it takes very long */ - if(!playlist.in_ram) { - if ( current_tick >= next_tick ) { - next_tick = current_tick + HZ; - snprintf(line, sizeof line, "%d files", - playlist.amount); - lcd_puts(0,1,line); - status_draw(); + store_index = false; + + if(playlist.in_ram || (*p != '#')) + { + /* Store a new entry */ + playlist.indices[ playlist.amount ] = i+count; + playlist.amount++; + if ( playlist.amount >= MAX_PLAYLIST_SIZE ) { + if(!playlist.in_ram) + close(fd); + + lcd_clear_display(); + lcd_puts(0,0,"Playlist"); + lcd_puts(0,1,"buffer full"); lcd_update(); + sleep(HZ*2); + lcd_clear_display(); + + return; } + + /* Update the screen if it takes very long */ + if(!playlist.in_ram) { + if ( current_tick >= next_tick ) { + next_tick = current_tick + HZ; + snprintf(line, sizeof line, "%d files", + playlist.amount); + lcd_puts(0,1,line); + status_draw(); + lcd_update(); + } + } } } } -- cgit v1.2.3