Advertisement

Which is faster....

Started by August 22, 2000 05:42 AM
3 comments, last by DefaultUser 24 years, 4 months ago
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!
The second method i think.

- Daniel
VG Games
- DanielMy homepage
Advertisement
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




[email=ehremo@hotmail.com][/email]
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
"Your superior intellect is no match for our puny weapons!"
HAHAHAHA! Good one.

I''ll leave now.
-Damnit Boy, have you been eating paint chips again?-Paint chips? Oh you mean "wall candy"?

This topic is closed to new replies.

Advertisement