How efficient is glm when it returns the result
Members - Reputation: 320
Posted 08 November 2012 - 11:56 PM
I see glm always returning a value instead which seems like it can be more expensive. I always think, is there some kind of compiler optimization or other stuff behind the scenes that makes the whole thing efficient after all and isn't something for me to worry about?
As an example of what I'm talking about:
[source lang="cpp"]//passing the result as a destinationvec3 result;dot(vecA, vecB, result);//returning the resultglm::vec3 result = glm::dot(vecA, vecB);[/source]
Members - Reputation: 841
Posted 09 November 2012 - 06:21 AM
- You are right, this is not something you should worry about, unless you have profiled your program and identified it as a performance bottleneck. Plus chances are that if it will be the bottleneck then simply passing destination as function argument will not help you.
- Yes, modern compilers should optimize out such assignments in release (optimized) mode.
First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/
Crossbones+ - Reputation: 9952
Posted 09 November 2012 - 07:02 AM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.