News for hackers. Stuff that matters.
Re:Goto (2007) by codr7 on Thursday October 21, 2021 @12:33PM (#28946991)
Re:Goto (2007) by slaymaker1907 on Thursday October 21, 2021 @12:48PM (#28947259)
Replying to infiniterand, a table of function pointers is going to generally have way more overhead than an indirect goto. An indirect goto is essentially a single assembly jump instruction. This is also often faster than a while loop plus switch since it is friendlier to the branch predictor.
Re:Goto (2007) by InfiniteRand on Thursday October 21, 2021 @12:39PM (#28947113)
I'm sure there's probably a reason for doing things this way, but it seems like that code would make more sense as a function pointer table and a series of functions. Was that not preferred for aesthetic reasons or for some specific technical reason?
Re:Goto (2007) by codr7 on Thursday October 21, 2021 @01:19PM (#28947772)
Speed.

Your suggestion adds indirect memory access plus function call, for every instruction.

I've tried every other way I can think of, and nothing runs faster from my experience.