HI Michael,

On Fri, Sep 4, 2009 at 3:56 PM, Michael Platings
<[email protected]> wrote:
> I accept your point about keeping code readable/maintainable so I've looked 
> at this again with a view to keeping the code readable, while making it 
> faster on all platforms.
> I've changed two loops:
> - I experimented with a wide range of bit-counting techniques to replace the 
> first loop (including some from here: 
> http://graphics.stanford.edu/~seander/bithacks.html). Typically only the 
> first 4 bits are set, so I've used the method that tested fastest for that 
> particular case (the Kernighan & Ritchie way).

This is hardly readable now is it.  I can't understand it from just
reading the code, I kinda doubt anyone else will be able to without
looking at the background reference material.  Very much a case of
fast but unreadable.

> - The second loop is largely unchanged, I've just replaced the iterator with 
> an index. This is faster for MSVC, and shouldn't make a significant 
> difference for other compilers. Arguably it also makes the code more readable.

Actually I would have thought it will be slower without the iterator.
The iterator should just be a pointer deference and a pointer
increment, using an array access requires an addition to a pointer
then a pointer deference and then an index increment.   The fact it's
slower under VS under debug build is a black mark for VS, not for the
use of iterators.

I'm sorry you are hitting problems with VS, but we really can't go
down the slippery slow of impairing code to workaround performance
issues on a specific compiler being used in a specific way.

Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to