Create temporary variable for epd + 0x5C/4 (2T 5A)
Patch condition by substituting temporary (2T 4A)
Run if statement (1T 1C 0A when target exists, 2T 1C 2A when target is empty)
Ideal behavior (~3T 1C 5A)
Patch condition by substituting constant and adding variable
VProc(epd, list(SetMemory(cond + 4, SetTo, 0x5C/4), epd.QueueAddTo(EPD(cond + 4))));
(2T 5A)
Run if statement (1T 1C 0A when target exists, 2T 1C 2A when target is empty)
Example 2
const target = epdcunitread_epd(epd + 0x5C/4);
Current behavior (~4T 12A)
Create temporary variable for epd + 0x5C/4 (2T 5A)
For function call, set parameter by substituting temporary (~2T 7A)
Run function body
Ideal behavior (~2T 8A)
For function call, set parameter by substituting constant and adding variable
VProc(epd, list(param.SetNumber(0x5C/4), epd.QueueAddTo(EPD(param.getValueAddr()))));
(~2T 8A)
Example 1
Current behavior (~5T 1C 9A)
epd + 0x5C/4
(2T 5A)Ideal behavior (~3T 1C 5A)
VProc(epd, list(SetMemory(cond + 4, SetTo, 0x5C/4), epd.QueueAddTo(EPD(cond + 4))));
(2T 5A)Example 2
Current behavior (~4T 12A)
epd + 0x5C/4
(2T 5A)Ideal behavior (~2T 8A)
VProc(epd, list(param.SetNumber(0x5C/4), epd.QueueAddTo(EPD(param.getValueAddr()))));
(~2T 8A)Similar to https://github.com/armoha/euddraft/issues/74 , this kind of optimization is only possible on epScript side.