Re: calloc.... Why?
From: JKop (NULL_at_NULL.NULL)
Date: 07/20/04
- Next message: John Harrison: "Re: problem with constructor/destructor?"
- Previous message: tonysuper: "Re: problem with constructor/destructor?"
- In reply to: tom_usenet: "Re: calloc.... Why?"
- Next in thread: tom_usenet: "Re: calloc.... Why?"
- Reply: tom_usenet: "Re: calloc.... Why?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 20 Jul 2004 12:30:03 GMT
tom_usenet posted:
> And using references doesn't make the optimizer's job any
easier IMHO.
> But it's likely that both versions will generate
identical code when
> inlined in the same context.
>
> Tom
It's not optimization at all, it's simply what inline
functions are all about. When a function is "outline",
arguments have to be passed to it in a certain way (stack
and registers), but when the function's inline, the stack
and registers aren't bothered with. So... with an inline
function; if you use const references, the compiler has no
optimation to do, it simply uses the objects in the calling
function. But if the arguments are by-value, then the
compiler actually would have to do an optimization to
realize that it can use the objects from the calling
function. Alternatively you could pass by-value and have
the objects const in the inline function, then the compiler
would know to use the objects from the calling function. I
prefer the const references, as it's very clear what's
going on.
-JKop
- Next message: John Harrison: "Re: problem with constructor/destructor?"
- Previous message: tonysuper: "Re: problem with constructor/destructor?"
- In reply to: tom_usenet: "Re: calloc.... Why?"
- Next in thread: tom_usenet: "Re: calloc.... Why?"
- Reply: tom_usenet: "Re: calloc.... Why?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|