J
Jan Bernatik
Hi
I have a function called from another one, which runs in loop, so that
is it called very often
something like this:
void my_function(int x) {
int temp;
temp = x * some_const;
do_something(temp);
}
suppose that x is changed really rarely ( lets say a hundreds of
calls)
would that be more efficient ?
void my_function(int x) {
static int temp;
if(temp != x * some_const)
temp = x * some_const;
do_something(temp);
}
why I'm asking is that I'm not sure, if creating temp variable in
every function call takes more time, then if statment. Anyone can
explain this to me a bit ?
thank's, have a nice day !
J.
I have a function called from another one, which runs in loop, so that
is it called very often
something like this:
void my_function(int x) {
int temp;
temp = x * some_const;
do_something(temp);
}
suppose that x is changed really rarely ( lets say a hundreds of
calls)
would that be more efficient ?
void my_function(int x) {
static int temp;
if(temp != x * some_const)
temp = x * some_const;
do_something(temp);
}
why I'm asking is that I'm not sure, if creating temp variable in
every function call takes more time, then if statment. Anyone can
explain this to me a bit ?
thank's, have a nice day !
J.