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!
Direct values is normally faster. It depends how the system was coded though.
I believe they are still faster but it is a small amount. If it is easy enough I would stick with direct values. If you have a lot of related code using that same value I would make it a variable.
If the arguments you are passing are constant parameters, it is good style to store them into named variables, e.g. JASS_MAX_ARRAY_SIZE versus say 0x2000. The compiler should inline these constants, which means you'll get the advantage of just using the actual value and not having to dereference a variable.
Direct values is normally faster. It depends how the system was coded though.
I believe they are still faster but it is a small amount. If it is easy enough I would stick with direct values. If you have a lot of related code using that same value I would make it a variable.
The 'compiler' is the vJASS script compiler, which indeed inlines constants (don't make constant handles apparently). The performance issue should only be considered if it is used a lot in a bottleneck of code. In the end it is a speed vs. readability decision that you have to make.To answer your question though; literals are faster than variables (a literal is often referred to as a constant).
The above is faster because it is a direct value. The unit and real are pointers. So think about a unit being in memory. (call it someunit)
For the above you point directly to the source object (the unit.) and return the x value. So this is 2 steps.
For the bottom one you first initialize a local object (the unit). Then load the unit and set the unit variable to the loaded unit. Next you initialize the real. Then you set the x value of the unit to it. To set the x it loads the local unit variable then it finds where the pointed object is. Then the x is set. So this is 5 steps.
Calling functions in jass is very slow. So when you have multiple function calls (2 or more) then the local variable initialization and pointer speed becomes faster than calling the function.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.