Re: An article I alluded to

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-07-26 at 21:06 -0600, Bill McEnaney wrote:
> Hi, everybody,
> 
> In another e-mail, I told you about an article that said that the
> computer can access static variables faster than it can access automatic
> variables.  So here's a link to that article.
> 
> http://www.numerix-dsp.com/appsnotes/c_coding.html
Whomever wrote it doesn't know what they're talking about, at least
not in regards to efficiency of storage access in general purpose
C compilers.

You're far better off using automatic storage for a variety of 
reasons.  Even when the variable can't live in a register and
thus has to live on the stack, it's generally still as efficient
or more efficient than static or heap variables.  There is no
extra indirection penalty for accessing stack storage.

In addition to the efficiency concerns, auto storage is thread
safe, statics are not.    auto storage doesn't require explicit
programmer management, heap storage generally does.


Most modern compilers ignore the "register" keyword, they actually
do a better job at determining what belongs in a regisrer than
most programmers.
Jeff


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux