Re: passing class to a function in c++ - performance question
From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 03/30/05
- Next message: Elias Pouloyiannis: "Re: How to encript header files."
- Previous message: BigBrian: "Re: passing class to a function in c++ - performance question"
- In reply to: Profil1: "passing class to a function in c++ - performance question"
- Next in thread: Gianni Mariani: "Re: passing class to a function in c++ - performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Mar 2005 13:09:45 +0200
Profil1 wrote:
>
> Hi,
> I'm writing a code that has to be as efficient as possible both in terms of
> memory use and execution speed. I'll have to pass a class instance (which is
> an 'intelligent' array) to a function (multiple times). Taking this into
> consideration, should I pass it as a pointer or reference? Is there any book
> or site that teaches stuff like this (optimizing code for performance)?
> thanks for any help
There is only one way to figure out: Time it.
But usually both methods (pass by pointer, pass per reference)
have equal performance. This is so, because the compiler implements
'pass per reference' by passing a pointer under the hood. So in
the end it turns out, that you do the very same thing with different
syntax.
-- Karl Heinz Buchegger kbuchegg@gascad.at
- Next message: Elias Pouloyiannis: "Re: How to encript header files."
- Previous message: BigBrian: "Re: passing class to a function in c++ - performance question"
- In reply to: Profil1: "passing class to a function in c++ - performance question"
- Next in thread: Gianni Mariani: "Re: passing class to a function in c++ - performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|