Do we really need const?

Bruce Adams tortoise_74 at yeah.who.co.uk
Tue Sep 18 12:28:32 PDT 2007


renoX Wrote:

> Janice Caron a écrit :
> > About passing structs by reference: It's one of those things, like
> > register or inline...
> > 
> > Once upon a time, programmers used the keyword "register" because they
> > thought they could do a better job than the compiler at figuring how
> > to use its registers.
> > 
> > Once upon a time, programmers used the keyword "inline" because they
> > thought they could do a better job than the compiler at figuring out
> > what to inline and what not.
> 
> Well in some (very limited) cases, they still do: I'm thinking about the 
>   Linux kernels where developers do care and know (at least in some 
> parts of the kernel) what the compiler do, of course this is not the 
> usual case..
>
Its not just in the Kernel. It comes up relatively frequently when dealing with large datasets using the STL. If your profile says a small function its taking the most time then inlining it can help. 
The compiler doesn't know and in general can't know how your code is going to be used, you need the execution profile for that.

Bruce.




More information about the Digitalmars-d mailing list