2.10.2011

Uncertain

I'm a bit uncertain about how inlining in C++ does optimize return values and references. After asking my lecturer he ensured my that reference never really consume any pointer or so and that I can always use it to get a better performance in general. Judging from the fact that I always used before and it was fast enough to make mass data access quick, I'll prefer instead of the return variant. So yeah, I guess this will be my last word for it. Always using references and so on. Hm, I must admit I doubted this for some days. I don't know. Maybe my brain turned into garbage after so many tries to get everything inline. That's weird, really. And now I'm also unsure about this loop unrolling stuff. Though I took a look at this page, knowing that -O does loop unrolling or when I specify it directly, I still ask myself if I can trust it. On the other side, how can I trust empty functions I used for complex, recursive template structures? The degree of possible is equal for both cases, so I can either not trust or be happy about it.

ARGH, sometimes I confuse myself enough with this shit to question everything I never questioned before cause someone told it me right. So it's a false assumption that unrolls later. *sigh* I should set up a definite guideline for my whole toolkit. I'll begin!
  • use only call by reference if possible
  • inline what's worth inlining
  • take loop unrolling serious and offer a large variety of template methods with fixed values to help the compiler determine what to unroll and what no
  • ensure that all unchanged reference are defined as const
  • make it a template class if useful and possible
So that seems like a good guideline. I should print and pin this somewhere for motivational and essential purposes...

No comments: