Re: Assigned gotos in standard C



"Adam" <adam.antonik@xxxxxxxxx> wrote in message news:9bfcd7c7-0821-4412-b22e-7380ccb8bbf2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I understand that a switch statement would allow this sort of flow
control; however, will this not lead to each jump requiring linear
time to compute, as the code works its way through each case?

No. If the case values span a limited range (eg. 0 to 255, with or without gaps), then a jumptable is likely used. This is very fast.

The overheads of a switch are testing the index is in range, and jumping back to the start of the switch.

--
Bartc

.