Which is faster....
Which is faster......passing a pointer to the function and work with it or returning a pointer after working with it.
Ex:
LPDIRECTDRAWSURFACE Func(...)
{
LPDIRECTDRAWSURFACE lpdds;
// Do some initializing stuff and return
return lpdds;
}
or
void Func(LPDIRECTDRAWSURFACE lpdds, ...)
{
// Initialize lpdds
}
-Thanks
Forget about that buggy code, let's start all-over - from scratch. Let's go!
to my knowledge neither is faster, the only thing is that with the first method, the variable will be allocated when the function is called... so it will be slightly slower
with something like initialising directx it''s completely unimportant since you only do it once in the whole course of your program, but i''m assuming that''s just an example and not the actual use
i wouldn''t worry about it too much, just go for which ever is more convenient
with something like initialising directx it''s completely unimportant since you only do it once in the whole course of your program, but i''m assuming that''s just an example and not the actual use
i wouldn''t worry about it too much, just go for which ever is more convenient
Yeah, just think about how many pointers have to be passed. It''s the same in each case: one. The first one passes a pointer upon exiting, and the second passes one upon entering. The allocation of the variable is the only difference, and this will only matter if you''re calling the function a couple thousand times every frame.
-Ironblayde
Aeon Software
-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement