Skip to main content
gamedev.net
🔒 Locked

speed question

Started by CProgrammer Oct 17, 2003 at 3:28 AM 2 replies 300+ views
Original Post
CProgrammer
CProgrammer
What would be the faster version of the following problem and which is preferably used: I have a recursive function which has an array(->a pointer) as an argument. Every time the recursive function is called it calls itself a variable amount of time therefore it needs to allocate new memory for the pointer copy the content and change it for all but one call. Is it better to allocate memory inside the recursive function or should i let the recursive process run twice? Meaning, once to get the amount of memory needed. Then allocate that memory and then go through the process again. -CProgrammer
Captian Goatse
Captian Goatse
My first question is whether this is runtime or not? So technically this cannot be answered unless we know what contex and purpose this is for.

Edit: Also is the funtion tail-recursive? If it is, then it would be faster to just do it once, because the compiler will allocate a buffer for it in the heap I think.

[edited by - Captian Goatse on October 17, 2003 7:31:45 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.