Rockbox mail archive
Subject: Re: A nasty inefficieny in file.c?
Re: A nasty inefficieny in file.c?
On 15/07/06, Jonathan Gordon <email@example.com> wrote:
> On 15/07/06, Magnus Holmgren <firstname.lastname@example.org> wrote:
> > Jens Arnold wrote:
> > > Another thought:
> > >
> > > Are you listening to mp3? Iirc Slasheri said that the id3
> > > parser is one such example of inefficiency as it reads
> > > byte-by-byte....
> > The id3 parser should read frame by frame, at least according to a quick
> > look at the code.
> > Other cases that do read char by char include the WPS reader and the
> > config file reader (both using misc.c:read_line). Maybe the WPS reader
> > is the main cause of these one byte reads in that short test run...
> shouldnt that read_line function be changed then to read X instead of
> 1 byte and then either cache the extra bytes read or move the fd back
> to the end of the new line?
possibly to something like this (untested code and it doesnt handle \r
int read_line(int fd, char* buffer, int buffer_size)
int count = 0;
int num_read = 0;
errno = 0;
num_read = read(fd, buffer, buffer_size);
buffer[num_read-1] = '\0';
if ( buffer[count] == '\n' )
buffer[count] = '\0';
// move the fd back to AFTER the \n if needed
return errno ? -1 : count;
> > Magnus
Received on Sat Jul 15 10:38:13 2006
Page was last modified "Jan 10 2012" The Rockbox Crew