Are there any reasons to choose one method over the other in the declaration
of local variables that are used each frame?
Here are some examples. Note that this hypothetical routine would be called
each pass through the EOM (for example):
============= Method 1)
MyClass::Calculate(double xyz)
{
double abc;
... <calculations> ...
if (price_of_tea_in_China > 0.45) {
abc = xyz*1.5;
}
ImportantValue = abc+24.0;
... <more calculations> ...
}
============= Method 2)
MyClass::Calculate(double xyz)
{
... <calculations> ...
if (price_of_tea_in_China > 0.45) {
double abc = xyz*1.5;
}
ImportantValue = abc+24.0;
... <more calculations> ...
}
============= Method 3)
class MyClass {
double abc;
void Calculate(double);
};
MyClass::Calculate(double xyz)
{
... <calculations> ...
if (price_of_tea_in_China > 0.45) {
abc = xyz*1.5;
}
ImportantValue = abc+24.0;
... <more calculations> ...
}
==============================
The general question boils down to this: Is it better to declare local
temporary variables actually as class members, or simply locals (and, if so,
does it matter whether they are declared at first use or at the beginning of
the function in which they appear)?
Jon
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel