Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

Cost of recursion

This topic is 3209 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to make a little script engineish program. Basically, I need to parse and handle multiple decision types ( if, for, while, etc ). These decisions can be nested within one another. In thinking about how to implement it, I've considered that I could call a function for each decision type. Three nested if's, therefore, would call the "if" function 3 times, recursively. Is there a better way to do this? How substantial will the hits from the additional call stack be, doing it recursively like this?

Share this post


Link to post
Share on other sites
Advertisement
Almost certainly negligible. But if you care, implement it and profile your program and see if it shows up as a bottleneck.

Share this post


Link to post
Share on other sites
How deeply nested ifs fors etc are you expecting?
20 would mean a monster-horror-killer structure, and that's only 20, it's negligible.
You have to consider storage/performance in flood-fill like situations (where there are branching, and the algorithm can fill thousands or millions of elements)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!