Quote Originally Posted by VladimirF View Post
Great analysis.
Thanks!

I think the conclusion should be: don’t presume that you can outrun modern compiler. At least, not before serious profiling.
Right. It may sometimes pay to try to give the compiler something that's easier to optimize, but it's almost never worth the effort trying to to coerce it into doing something it wouldn't have done naturally anyway.

IMO this "clustered cases" optimization is rather specific, yet practice shows that this is a quite common scenario in everyday programming, so it's worth the effort to program that into the compiler.

Offtop: Sorry Eri, but I am not allowed to rate your posts
I was able to rate yours, so this does not seem to be due to the current problems with the forum software. (This specifc post of yours may not actually have deserved a rating, but I think overall you deserve one from me from time to time... ) The last rating I got from you (thanks again ) was from Feb 29th, almost four weeks ago, but AFAICT the point in time when you can come back and rate a user's post again also depends on how many ratigngs you gave to other users in the meantime. So it's not so easy to calculate...