27 ms·
The comment "Why are you writing to a member in an inner loop? Use a local in a register. Why make the compiler guess at something you know?" is misguided. Simp
by scott_s 17y ago
The comment "Why are you writing to a member in an inner loop? Use a local in a register. Why make the compiler guess at something you know?" is misguided. Simply, why muddy-up your own code when the compiler will probably do the work for you? Your time is valuable. The compiler won't complain if you make it work a little bit more.
- malkia 17y agoYes, it would. But this comes from a game developer, being one myself - we often need DEBUG builds that are relatively fast, because you develop your game mostly in such build (well not real DEBUG, but almost). For that reason, anything you can do help the compiler even if it's not optimizing is good. For example overriding operators such +, -, for say matrices/vectors might seem good idea (off course inlined, etc.) - but in DEBUG it creates such overhead, especially if it's nested. Instead use simple function call. Check Mike's page (cellperformance.com) - http://www.cellperformance.com/ http://www.cellperformance.com/
- scott_s 17y agoI do high performance systems research - half of the time using the Cell, coincidentally - and I've learned to just write straight-forward, idiomatic C/C++ as much as possible. I'd only perform the kind of optimization the author suggests if I knew for sure that code was my bottleneck.