Skip to content

[epScript] Reduce overuse of DoActions in basic actions #36

@armoha

Description

@armoha

Copied from phu54321/eudplib#9 and phu54321/epScript#5

function afterTriggerExec() {
  while(Bring(P1, AtLeast, 1, "Zerg Drone", "Anywhere")) {
    MoveLocation("loc", "Zerg Drone", P1, "Anywhere");
    RemoveUnitAt(1, "Zerg Drone", "loc", P1);
    CreateUnit(1, "Zerg Mutalisk", "loc", P1);
  }
}

/* __epspy__ makes 3 Triggers for 3 actions, 2 objects are wasted.
It should use 1 DoActions in a series of actions for performance and map file size.
def afterTriggerExec():
  if EUDWhile()(Bring(P1, AtLeast, 1, "Zerg Drone", "Anywhere")):
    DoActions(MoveLocation("loc", "Zerg Drone", P1, "Anywhere"))
    DoActions(RemoveUnitAt(1, "Zerg Drone", "loc", P1))
    DoActions(CreateUnit(1, "Zerg Mutalisk", "loc", P1))
  EUDEndWhile()
*/

We had partial success on optimizing if block by armoha/eudplib@dfc2569 since euddraft 0.9.3.3. But optimizing trigger actions will improve much more performance than conditions. Unlike conditionals, this is hard to resolve in eudplib so fixing epScript compiler to recognize basic actions to merge would be a way to go.

Stepwise tasks from easiest to hardest one.

  • Optimize sequence of basic actions with constant arguments.
  • Optimize basic actions with ConstExpr. (example: var += 1; array[0] = 2; SetMemory(db, SetTo, 3);)
  • Optimize actions with runtime patch to SeqCompute or VProc if possible.
  • Optimize custom user-defined actions.
    It would be impossible to optimize any epScript code which import eudplib module so there should be a way to define and use custom action in epScript.

Related parser rule:
https://github.com/armoha/eudplib/blob/855a4e8c97b57f4bb432787ef28f05d77d669287/eudplib/epscript/cpp/parser/epparser.lemon#L1193-L1197

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions