Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: arrays & pointers

Re: arrays & pointers

From: Björn Stenberg <bjorn_at_haxx.se>
Date: 2005-01-29

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/rockbox
Received on Sat Jan 29 13:46:50 2005

Page was last modified "Jan 10 2012" The Rockbox Crew
aaa