I can't seem to find a way to detemine unit type other than using dynamic_cast. Is this correct? If so, I think we desperately need a flag in the Unit base class to tell which type of unit it is.
they aren't THAT slow in our case, we have a very flat hierarchy, so it's usually one-two lookups away. i don't believe there's any significant speedup to gain by removing dynamic_cast and IIRC profiles confirm that.
Are dynamic casts really slower then an if and a static_cast? Do you have measurements to support that? Do the dynamic_casts occur in time critical code in which any speed difference actually matters?
After all an if and a static_cast is pretty much the only thing the compiler has to generate to implement a dynamic_cast.
I don't think dynamic_casts are (can be) uglier then static_cast or const_cast, and those seem to be introduced into the codebase, rather then removed, so better keep that consistent. Either remove all C++ style casts or also keep the dynamic_casts.
the benchmark is interesting but rather useless - it doesn't compare gcc and, more importantly, omits code... speed of dynamic_cast is very dependent on the class hierarchy it has to traverse.
I'm not sure it's worth your time to change it all across the code. I'd like to see a profile of a /skipped replay before and after to see if it was indeed worth it.