Questions about optimisation and errors

Level 6
Joined
Mar 9, 2023
Messages
75
Hi!

I have a few questions that are unclear to me in JASS. I'm chasing a great bug that causes enemies with very girthy hashtable scripts to randomly die. Very hard to replicate playing solo.

1. How important is it to declare real variables with .X afterwards? Can not doing it cause issues?
2. How many handles and keys can a single hashtable contain? Can it fill up?
3. How important is it to add null checks in code that refer to units as variables?

Thanks!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
As far as I know:

1) No issues.
2) 200k entries based on what I've read but I would assume millions. The Hashtable limit is 255.
3) It can be very important depending on what you're doing. Better safe than sorry. It's more of a problem in custom functions since Blizzard functions seem to always have null checks.
 
Level 6
Joined
Mar 9, 2023
Messages
75
As far as I know:

1) No issues.
2) 200k entries based on what I've read but I would assume millions. The Hashtable limit is 255.
3) It can be very important depending on what you're doing. Better safe than sorry. It's more of a problem in custom functions since Blizzard functions seem to always have null checks.
Thanks Uncle! I'll implement more null checks! :D
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
1. How important is it to declare real variables with .X afterwards? Can not doing it cause issues?
As far as I am aware the declared name of real variables does not matter. Technically longer names are slower due to how hashing of names works (no static linking).

I do not think '.' is supported in variable names. If using vJASS then the vJASS precompiler is converting those into valid variable names on map save. So something like 'structinstance.X' converts to an 'real array structinstance_X' where the index is the struct instance reference.
2. How many handles and keys can a single hashtable contain? Can it fill up?
A lot. This is mostly an issue with performance as it has a limited bucket array size so as it fills up its performance degrades towards O(n) instead of O(1). I think the issues start in the 100,000 entry range.
How important is it to add null checks in code that refer to units as variables?
Quite. Although some natives have internal null checks, others might not. From a logical point of view it makes no sense trying to run code on something that is null, even if safeties catch the case.
 
Top