SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Technology Stocks : Intel Corporation (INTC) -- Ignore unavailable to you. Want to Upgrade?


To: Joe NYC who wrote (151258)12/5/2001 7:56:29 PM
From: wanna_bmw  Respond to of 186894
 
Joe, Re: "But to do the lookup, each single case needs to be examined, which is the variable here."

That's what I assumed, at first. But then Kap mentioned that compilers are likely to set up some kind of a table for the switch statement. When the switch variable is calculated, it will be translated into a pointer for the next instruction. That's much more efficient than stepping through every case statement. However, it still requires a branch, and these branches will not be able to be predicted. Thus, if the processor makes a guess, fills the pipeline, and later finds out that it was incorrect, it will need to flush the pipeline, and begin over. For a longer pipeline, this will obviously mean far more latency.

wbmw