3 ms·
If you put a dynamically dispatched function call in the middle of a tight loop you will slow it down significantly. As I say in the talk in most code it just d
by josephlord 11y ago
If you put a dynamically dispatched function call in the middle of a tight loop you will slow it down significantly. As I say in the talk in most code it just doesn't matter. It is all relative. A function call is fast relative to a context switch or and I/O operation.
If you think what is required to call an instance method on the class it is significant. Roughly, read the address of the object, read the pointer to the class, read the vtable of the class for the function pointer then set registers and stack values and make the function call.
In ObjC method calls are actually via objcmsg_send calls to do the dynamic dispatch.
Computers are fast and they do these things quickly but not having to do them is much faster.