Implement faster is_a<>()

This implementation uses typeid() which is faster than dynamic_cast<>().

Before: 2828ms
After: 2482ms