|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Performance Programming Applied to C++ |
|
![]() Anonymous Poster |
||||
|
||||
| I've created a site that describes lots of performance problems and some solutions, along with a few related links and references. Enjoy! http://members.optusnet.com.au/speedup |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| >> b/a + c/a = (1/a)*(b+c) <<
It would probably be more efficient to use
b/a + c/a = (b+c)/a
as we don't get the multiplication at all... :-)
|
||||
|
||||
![]() big_o Member since: 7/19/2006 From: Baltimore, MD, United States |
||||
|
|
||||
| Anonymous Poster II: My thoughts exactly; (b + c)/a seems best. But, the idea that multiplication is faster than division is important to establish. (That's why I looked the article up in the first place.) Here's a common enough example of that -- finding a unit vector: Vector3f to_uvector() { float magnitude_mult = 1.0 / sqrt(x*x + y*y + z*z); return Vector3f(x * magnitude_mult, y * magnitude_mult, z * magnitude_mult); } Something I didn't see in the article -- passing struct/class arguments by reference/pointer. For example, if you write a function to find the dot product of two vectors, it's my impression that passing the second by reference (as in, float Vector3f::dot(Vector3f &vectorB)) will eliminate an extra call to the copy constructor. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|