• 🏆 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!

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