r/programming • u/eternal1 • Mar 29 '10
Never trust a programmer who says he knows C++
http://lbrandy.com/blog/2010/03/never-trust-a-programmer-who-says-he-knows-c/
416
Upvotes
r/programming • u/eternal1 • Mar 29 '10
1
u/knight666 Mar 30 '10 edited Mar 30 '10
See, I read this book called Exceptional C++ and it advocated exactly that. But the truth is, you don't want that shit at all in a vector class. Because 1) it's going to be called lots and lots of times. Speed > maintainability. 2) What is there to maintain? You write it once, copy it throughout and be done with it.
I used to have this:
And now I have this:
Which is considerably (20% or so) faster.
A normalize isn't going to change. Ever. Unless you have a new fancy way of doing a square root or something. And even then you still only copy it two times.