On 19/04/2015 at 13:36, xxxxxxxx wrote:
At least for GetVirtualObjects(), you can use GetAndCheckHierarchyClone() to check if the object needs to be recreated or not (if it is dirty or not). If not, the returned clone can be returned. Not sure if this applies with GetContour().
// Check if needs rebuild and get cloned hierarchy of input objects
Bool dirty = FALSE;
mainop = op->GetAndCheckHierarchyClone(hh, child, HIERARCHYCLONEFLAGS_ASPOLY, &dirty, NULL, TRUE);
// - if !dirty then object is already cached and doesn't need to be rebuilt
if (!dirty) return mainop;
As for 'complex calculation', anything (and I literally mean *ANYTHING* ) that can be done once or preprocessed should not be done every time you do this complex calculation. I would need to see your calculation code in order to offer places to do this - but you should be able to see easily where calculations are invariant and could be done beforehand and then used to enhance speed and reduce complexity. For instance, if you are dividing real numbers with a real number (say, Q) repeatedly, take the inverse of that real number (1/Q) and multiply. Division is slower than multiplication in floats. Avoid Sqrt() whenever possible - again, any calculation to a particular value that is being done more than once (esp. in loops) needs to be done outside of the loop or just once into a variable and reused.