4 ms·
https://github.com/codr7/ampl/blob/main/src/ampl/eval.cpp https://github.com/codr7/ampl/blob/main/src/ampl/eval.cpp
by codr7 5y ago
https://github.com/codr7/ampl/blob/main/src/ampl/eval.cpp https://github.com/codr7/ampl/blob/main/src/ampl/eval.cpp
- InfiniteRand 5y agoI'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?
- codr7 5y agoSpeed. 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.
- slaymaker1907 5y agoReplying 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.