Is FastPointers good to get too many pointers?

Blitz3D Forums/Blitz3D Beginners Area/Is FastPointers good to get too many pointers?

eNano(Posted 2013) [#1]
Hi,
Suppose I need to obtain the pointers of many functions of my code (like 100 pointers just to give any amount), those functions doesn't have to be called in realtime, just once in a while.
Is there any memory or efficiency disadvantage about doing that?

Thanks a lot!


Yasha(Posted 2013) [#2]
FastPointer is currently the only way to get function pointers in B3D, so... you don't really have any option if your algorithm needs function pointers!

But no, there's not much disadvantage. Calls are slightly slower because they have to go through an extra layer in the DLL, but this is going to add only a few nanoseconds and might not even be measurable. There is no dynamic memory cost at all, as nothing is allocated (the DLL adds a stack frame per call, but that's a nonissue for any normal program). Since nothing is allocated, the number of pointers you take won't make any difference at all and you can use as many as you like.

Besides, anything that only happens once in a while doesn't usually need to be fast anyway.


FastPointer is about as fast as such things can be made, so it should be perfectly fine - I've found it's quite fast enough for realtime, anyway. You certainly don't need to mess your program about by rewriting everything to use If or Select.


eNano(Posted 2013) [#3]
Thanks a lot Yasha! This are great news, I'll start messing around with pointers then.