If the block is against the Switch-Case block

Typically, is there a performance difference between an if block with many other ifs compared to a case switch block? Do some languages ​​or style conventions prefer each other?

In particular, I am interested to learn about Matlab, C and C ++

+5
source share
2 answers

In some cases, the switch can be optimized by the compiler in the lookup table and branches. This can be significantly faster than multiple if / else-ifs.

+3
source

C jmp, . , .

+1

All Articles