Original Post
Hi every one. Recently i start (re)designing my (crappy) physics engine, and wanna add polymorphism(virtual functions) in to make it more flexible. Since virtual functions will probablely introduce some overhead, in some speed critical parts, i'm gonna replace them with function pointers, which i think have the same underlying implementation as normal function call, and should be the fastest i can get. But after reading from somewhere, that isn't always the case.[oh] Another problem is that FP has very bad support and ugly syntax for member functions, which motivates me to find an alternative. After googling, I came across this article, it claims "invoking a single-target delegate is as fast as a normal function call", and has much better syntax ans support for member functions. It really sounds promising. Basically, what i wanna ask are: 1)Is Function pointer call always as fast as normal function call? 2)Will replacing branching(if...elseif...) with FP array be faster? 3) Are Delegates really that fast? 4)Can i widely adopt Deleagtes, and replace all the FP(if possible)? [Edited by - wanzi on October 15, 2005 9:01:02 PM]