On Mon, Apr 10, 2006 at 04:18:56PM -0700, David Leimbach wrote:
> Interesting example...
> 
> SomeContainer::iterator it = SomeContainerObject.begin();
> 
> for (; it != SomeContainerObject.end(); ++it)
> 
> is probably a lot faster than
> 
> for(; it != SomeConatinerObject.end(); it++)
> 
> And I'd bet that not much more than half of the so-called C++
> programmers out there in the world know why this is.

  If the punch line here is, in fact, what I think it is, then
  a good optimizing compiler should be able to make these two
  pretty close in terms of performance. 

  I've been doing optimizing compilers at Sun for quite some time
  now (C/C++ and Fortran) and one thing that I constantly talk
  to our customers about is that in todays world of opaque CPU
  design they actually don't know whether 'a = a + 1;' is slower
  or faster than 'a++;'. So the best advice I can give them 
  is to:
     
     1. Express semantics, not how to generate code
     2. Pick a compiler vendor you can trust.
     3. Make Performance Analysis part of your debugging.

 
Thanks,
Roman.

Reply via email to