• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Vexorian Map Optimizer does not optimize operations

Status
Not open for further replies.
So, I just optimized my map and then decided to check if my code had been properly optimized where I wanted. However, I was pretty shocked to find that the optimzier does not optimize operations that will always yield the same result.

JASS:
set DB[K3+2*$C]=DB[K3+2*$C]+$80

As you can see, 2*$C is clearly an optimizable operation that will always yield 24 ($18 in hexadecimal). However, the optimizer still leaves it as a costly JASS operation instead of changing it to a number. I thought this would be one of the first optimizations to be considered.

JASS:
 set udg_save_XYminmaxcur[playerNumber+2*bj_MAX_PLAYERS] = udg_save_XYminmaxcur[playerNumber+2*bj_MAX_PLAYERS] + 128

As you can see, the optimizer is correctly removing the constant variables in the code and replacing them with the actual value. I thought this might be the problem, maybe the optimizer was optimizing operations first and then replacing constants, but....

JASS:
function IsDestructableTree takes destructable dest returns boolean
    local boolean result = false
    call BJDebugMsg((I2S(1+2)))

JASS:
function TW takes destructable UW returns boolean
local boolean WW=false
call BJDebugMsg((I2S(1+2)))

Even when the actual number is already written in the code, the optimizer will not optimize the operations.

So my question is, am I doing something wrong in the settings? If not, is there any optimizer out there that will take care of these predictable operations?

Thanks for your help.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Damn, I really thought it would optimize the script in these cases... oh well, maybe I or someone else will find the time to write such an optimizer one day, considering that JASS math is pretty slow.
Apparently Wurst does have a proper optimizer which will produce optimized JASS from Wurst script.

That said without an explicit language or commands it is very hard to optimize JASS due to the language features.
 
Status
Not open for further replies.
Top