Hacker News new | ask | show | jobs
by ncmncm 1718 days ago
It is quite common for any heavily inlined code to have lots of dead sections. Template code is very frequently heavily inlined. So, it is common for compilers to prune out the dead branches.

But C code is often heavily inlined, too, and similarly pruned.

1 comments

Guess I need to pay more attention to the template code I use. I knew that they tended to rely very heavily on inlining for good performance, but I haven't read as much about the presence/absence of dead code, though to be fair maybe the deadness isn't always obvious to the programmer?

In any case, thanks for correcting me!

I should add that most of the Standard library will not often have many visibly dead code branches to prune. Most of what gets discarded is arguments and calls to no-op functions, all the scaffolding. But there is a lot of that. So, for example, an iterator on std::function isn't typically a pointer, but after optimization the instructions left standing are the same as if it was one.
Oops: s/std::function/std::vector/