• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Arrays with empty index

Status
Not open for further replies.
So usually when working on large values, I set the array's max index to 100 so I don't have to worry about adjusting it every time I think of adding another value to the array.

My question is, is that good practice? Say if I only filled up a quarter of it, would the remaining empty indices affect the file size, or anything that would cause problems in a long playthrough of the map?
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
I don't know how much it can affect the game but it's probably very minimum and unnoticeable, unless you're using a much bigger array size than you mentioned, of course.
The remaining empty indices will surely make that declared array consume more memory if i'm not mistaken.
It's best practice to set it just as many as it's required. But what you're doing should be okay, too.
Just make sure to minimize the redundancy as much as possible.

Feel free to correct me if I get it wrong, though.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If you are talking about GUI/Jass (i.e. your map doesn't use the new Lua mode), the size of every array is always the same - 32768 (defined with JASS_MAX_ARRAY_SIZE).
When you set the size in the variable editor, it only selects how many of the elements to initialize with some default value.
For example, if you have an array of timers, and you tell the variable editor you want 10 timers, the first 10 timers in the array will be set, and the other 32758 elements will be null.
This isn't relevant to primitives like numbers, which will always be set to 0 (unless you can also set the default value itself in the variable editor? I honestly don't remember).
 
Status
Not open for further replies.
Top