#27018 - ScottLininger - Fri Oct 01, 2004 6:04 pm
I'm working on an RPG engine that fires "events" when certain interactions occur. I'm handling these event calls via function pointers.
Every "actor" in the game has several events that could potentially be fired, but many of these events will do nothing. For example, there is an OnTick event that fires every frame that the PC is touching a given actor. For 90% of the actors on the map, this event will do nothing.
So my question is this: Is it more efficient to do an IF/THEN to decide whether to call the event function (saving the function call overhead 90% of the time), or to simply call an empty function that does nothing?
The functions themselves would at most accept 2 parameters.
This is definitely a *minor* performance concern, but I'm just curious.
Thanks!
-Scott
Every "actor" in the game has several events that could potentially be fired, but many of these events will do nothing. For example, there is an OnTick event that fires every frame that the PC is touching a given actor. For 90% of the actors on the map, this event will do nothing.
So my question is this: Is it more efficient to do an IF/THEN to decide whether to call the event function (saving the function call overhead 90% of the time), or to simply call an empty function that does nothing?
The functions themselves would at most accept 2 parameters.
This is definitely a *minor* performance concern, but I'm just curious.
Thanks!
-Scott