icefox tests issues

Zack Rusin zack at kde.org
Wed Oct 20 22:21:56 CEST 2004


On Wednesday 20 October 2004 13:35, Matt Rogers wrote:
> AFAIK, using it++ in Qt/KDE is worse because a temporary object is
> created, but i could be _completely_ wrong. So this _might_ (very
> slim possibility) cause a speedup, but caching the value of end()
> might have more effect.

This is not really true for complex types. 
For example:
class A {
 class Itr {
  Itr operator++(int) {
   Itr tmp = *this;
   ++(*this);
   return tmp;
  }
 };
};
Now in order to optimize this we would need to have intimate knowledge 
of what the copy constructor on those bad boys do. If we would have 
even the simplest code in there like
"... ++globalCopies; ... " where globalCopies is some static var then 
we're done. So essentially for C++ programs compilers optimize the 
post-increment only for basic types. Everything else is either not 
touched at all or just very loosely checked and you should never depend 
that you even have a shot at compiler optimizing it for you.

Zack

-- 
Friends don't set friends on fire


More information about the Kde-optimize mailing list