Regarding having lots of variables

Started by planetfall, September 28, 2014, 11:14:02 AM

Previous topic - Next topic

planetfall

Is there a. any limit on the number of variables per script, and b. significant slowdown with accessing variables when there are a ton of them?

I ask because I need a way to store information about individual cells, for things like the sanctuary shield and some other ideas I have. The way I've found to do this is to have an off-map core with a known UID and a mostly blank script, and the variable names themselves refer to the cell. This seems to be faster than iterating over a single list variable to find the right cell, and more hassle-free than creating nested lists and ensuring they always remain the same size.

However, if it won't work, it won't work. :P
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

knucracker

Variables in CRPL are stored in an internal hashmap.  So you can have a whole lot of them without any real slowdown.  If you create millions, then a lot of game memory will be used.  But other than that the hashmap is O(1) access time.  (Of course the hashmap has to allocate new memory as it grows, but once done that one-time performance cost is paid).


planetfall

Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.