BaseContainer Performance
- 
 THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED On 29/08/2006 at 07:47, xxxxxxxx wrote: User Information: 
 Cinema 4D Version: 9.6
 Platform: Windows ; Mac ;
 Language(s) : C++ ;--------- 
 Hi,I have a general question concerning getting values out of a BaseContainer instance. I need some values from my plugin object several times in a calculation, so I am asking myself if it´s faster to store the value from the basecontainer in a variable of mine and use this one or if it´s performance-wise the same if I´d retrieve the values directly from the basecontainer? I assume the former is the case but I am not absolutely sure. Thanks 
 Katachi
- 
 THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED On 29/08/2006 at 09:50, xxxxxxxx wrote: Most definitely faster to use a variable to store the BaseContainer value if you are going to use it more than once. This will be slow if done multiple times: x = m * obj->GetDataInstance()->GetReal(ID_MYREAL); 
 y = n * obj->GetDataInstance()->GetReal(ID_MYREAL);
 z = o * obj->GetDataInstance()->GetReal(ID_MYREAL);This won't be quite as slow: BaseContainer* bc = obj->GetDataInstance(); 
 x = m * bc->GetReal(ID_MYREAL);
 y = n * bc->GetReal(ID_MYREAL);
 z = o * bc->GetReal(ID_MYREAL);But this is better: BaseContainer* bc = obj->GetDataInstance(); 
 r = bc->GetReal(ID_MYREAL);
 x = m * r;
 y = n * r;
 z = o * r;Of course, you should weigh how many times you'll need to reference the BaseContainer to set or get values as well as how often the values are needed. For a one-off use, the quickest method would be (and avoid the stack variables) : x = m * obj->GetDataInstance()->GetReal(ID_MYREAL); 
- 
 THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED On 29/08/2006 at 10:01, xxxxxxxx wrote: Hi Kuro, thanks, that confirms what I am currently doing. Thanks for the check! 