|
Rockbox mail archiveSubject: Re: arrays & pointersRe: arrays & pointers
From: Björn Stenberg <bjorn_at_haxx.se>
Date: Sat, 29 Jan 2005 13:45:14 +0100 Nix wrote: > Could you describe the inefficiency you see in more detail? Some sample > C that demonstrates the inefficiency would be great. See this patch: http://www.rockbox.org/viewcvs.cgi/firmware/common/dir.c?r1=1.25&r2=1.26 What it does is change array-using code into pointer-using code. From this: /* find a free dir descriptor */ for ( dd=0; dd<MAX_OPEN_DIRS; dd++ ) if ( !opendirs[dd].busy ) break; into this: DIR* pdir = opendirs; /* find a free dir descriptor */ for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++) if ( !pdir->busy ) break; It does this in a couple of places, which all in all gives roughly 250 bytes shorter code. -- Björn _______________________________________________ http://cool.haxx.se/mailman/listinfo/rockboxReceived on 2005-01-29 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |