For a data analysis program I am using a library which solely uses dynamic_cast
instead of static_cast
.
After profiling and optimizing my own code, valgrind shows me that my program is spending roughly 50% of the time doing dynamic_cast
in library code. As this library is open source I have replaced all relevant dynamic_cast
with static_cast
. The library builds just fine, but as I do not have a deeper understanding of the library code I do not know if I have broken anything.
- Can I break anything by replacing
dynamic_cast
withstatic_cast
? (besides the build process) - If yes, which cases are foolproof and for what kind of problems do I have to look out for?
- Is my impression correct, that I can considerably improve the run time of my program by doing this replacement? Or am I just shifting problems around?