2021年3月3日星期三

Which of these is more efficient to choose a function?

So lets say I have 2 functions to choose from based on whether number is even or odd. I came up with this:

(void (*[])()){f1 ,f2}[n%2]();.

Is it more or less efficient than simply:

n%2 ? f2() : f1();

https://stackoverflow.com/questions/66467477/which-of-these-is-more-efficient-to-choose-a-function March 04, 2021 at 09:53AM

没有评论:

发表评论