3 ms·
There sure are lots of "fairly sure", "I feel" and "I think" comments in this thread. I'm inclined to accept that Alice Goldfuss knows what theyre talking abou
by kibibu 4y ago
There sure are lots of "fairly sure", "I feel" and "I think" comments in this thread.
I'm inclined to accept that Alice Goldfuss knows what theyre talking about, partly because their twitter is full of good tech stuff, and partly because I too have encountered situations where switching from a big branchy case statement to function pointers improved performance significantly.
- jacknews 4y agoThat's because there's no right or wrong answer about this, and people on here are not just a bunch of juniors who should automatically accept as an authority anyone who blogs. If switch/case actually does compare each and every item, as the article claims, then obviously a dispatch table is a solid choice to improve performance. But that is just not likely the case in this example (and it does depend on a number of factors), and so it's then largely a matter of taste. This technique definitely has it's place, but this example is not the best, um, case, IMHO.