• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] DS Stacks and Queues performance

W

Wayfarer

Guest
Are DS Stacks and Queues the most performant of the data structures if you simply need a list where indexing doesn't matter?

Is it efficient assigning them to a local variable and then using ds_stack_destroy(id) at the end of the script (for something that happens every step). What are they like compared to arrays in such a situation?

I'm going to do some tests myself, but if anyone already has some knowledge on this that'd be helpful.
 
Q

Quackertree

Guest
Yes, stacks & queues are faster than ordered lists, as the data structure doesn't have to take index into account. However, this "speed boost" tends to be quite minor (in my experience), although it should be slightly faster.

Creating and destroying data structures is always super slow, however. If you're running the same script over and over and you're using the same struct for the same script everytime, it's best to initialize it once (since it won't be destroyed at random, like surfaces are) and clear it once your script begins.
 
Top