• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Remove point efficiency

Status
Not open for further replies.
I am wondering which of these two versions of a trigger is the most efficient.


  • Unit Group - Pick every unit in Temp_Unit_Group_1 and do (Actions)
    • Loop - Actions
      • Set Temp_Point_1 = (Position of (Picked unit))
      • Set Temp_Point_2 = (Temp_Point_1 offset by 16.00 towards Temp_Real_1 degrees)
      • Unit - Move (Picked unit) instantly to Temp_Point_2
      • Custom script: call RemoveLocation (udg_Temp_Point_1)
      • Custom script: call RemoveLocation (udg_Temp_Point_2)
  • Unit Group - Pick every unit in Temp_Unit_Group_1 and do (Actions)
    • Loop - Actions
      • Set Temp_Integer_1 = (Temp_Integer_1 + 1)
      • Set Temp_Point_1[Temp_Integer_1] = (Position of (Picked unit))
      • Set Temp_Point_2[Temp_Integer_1] = (Temp_Point_1[Temp_Integer_1] offset by 16.00 towards Temp_Real_1 degrees)
      • Unit - Move (Picked unit) instantly to Temp_Point_2[Temp_Integer_1]
  • For each (Integer INTEGER_001) from 1 to Temp_Integer_1, do (Actions)
    • Loop - Actions
      • Custom script: call RemoveLocation (udg_Temp_Point_1[INTEGER_001])
      • Custom script: call RemoveLocation (udg_Temp_Point_2[INTEGER_001])
 
Level 5
Joined
May 6, 2013
Messages
125
The First one will most likely execute faster as it has less overhead, but if you have a trigger that does a lot of stuff in a short amount of time (like, when your unit group grows rediculously large), doing the cleanup at a later point in time (after a timer or maybe after another event) might be the smarter approach indeed. Procrastination to a time where you have less to do, if you will.
 
The First one will most likely execute faster as it has less overhead, but if you have a trigger that does a lot of stuff in a short amount of time (like, when your unit group grows rediculously large), doing the cleanup at a later point in time (after a timer or maybe after another event) might be the smarter approach indeed. Procrastination to a time where you have less to do, if you will.

The clarifying answer I was looking for. Thanks Imp.
 
Never do it like in 2nd exampe, even you have "a lot" todo as was said. Sorry but I would not understand it.

Imp Midna what would scare you to run these functions in same iteration? Only more useless operations would run with this extra loop, not?

Also the way with loop does need an array --> again slower.

Edit:

If you want it more efficient you can use coordinates only and no locations. Also using a loop + indexing is more efficient than using UnitGroup iterations.
 
Status
Not open for further replies.
Top