"0to60" <holeshot60_nospam_@yahoo.com> wrote in message
news:Cabvb.31516$. com...
> I don't know if I have that terminology right, but does anyone know if
> static member functions (or free standing functions for that matter) are
any
> less overhead than actual member functions that operate on an instance of
> that class?
It's compiler dependent. You'll have to do some tests. A given compiler on a
given machine might pass the 'this' pointer in a CPU register to a
non-static member function, but pass an explicit object pointer argument to
a static function on the stack (i.e., in regular RAM). I'd expect a good
compiler to make a non-static member function at least as efficient as a
static function that does the same thing, but you can only find out by
running tests.
> I'm writing a math calculator that responds to real time data and it needs
> to be FREAKY fast. To minimize the number of arguments that certain
methods
> take, I have stored some data within a class and made those methods
operate
> on that instance's data. But other functions DON'T operate on that data;
> they need data passed to them. Should I make those latter functions
static,
> instance members, or maybe even free standing functions?
Any non-virtual member functions that don't use any member data can be made
static. I'd expect a slight improvement in speed because no 'this' pointer
needs to be passed to them. But, again, you can't be sure without running
tests.
DW
|