| 05-19-2006, 12:07 PM | #1 |
What is most efficient? I would think example 2. example 1: example 2: Actions![]() Unit - Kill Footman 0001 <gen>![]() Unit - Kill Footman 0011 <gen>![]() Unit - Kill Footman 0012 <gen> |
| 05-19-2006, 12:09 PM | #2 |
2nd example. In the first example you first save the contents of 3 variables in 3 different array slots, and then loop through the array killing the units. Just 3 times KillUnit without the loop is better, as it won't have to set variables (GUI loops also uses variables). |
| 05-19-2006, 12:09 PM | #3 |
So this means that going through a loop to for example move a unit around another using the degree as a real variable is worse then moving the unit as in example 2? but in a case like this one below, its better to use a loop I assume? or is it? cause I do one call and one "set variable" instead of just one call. Thou I save some space. example 3: But then this would be the best: JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local integer a = 1 loop exitwhen a > 36 call SetUnitPositionLoc( gg_unit_hfoo_0001, PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), 100.00, I2R(a * 10)) ) set a = a + 1 endloop endfunction |
| 05-19-2006, 12:24 PM | #4 |
Yes, it would be best, but the code obove leaks as hell. 36*2 locations which are never removed. |
| 05-19-2006, 01:19 PM | #5 |
I know :P |
| 05-19-2006, 01:34 PM | #6 |
second one |
| 05-19-2006, 02:06 PM | #7 |
exactly why would the second be better? the only reason I could think about is that it uses local JASS loop instead of GUI's for loop . But besides of that both seem pretty unefficient. I2R(a * 10) No need at all for the I2R Not a lot of difference between increasing the real and making the product everytime. JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local real a = 10 loop exitwhen a > 360 call SetUnitPositionLoc( gg_unit_hfoo_0001, PolarProjectionBJ(GetUnitLoc(GetTriggerUnit()), 100.00, a) ) set a = a + 10 endloop endfunction Of course, the whole function is absurd, besides of the leaks this function wouldn't really work. |
| 05-19-2006, 02:12 PM | #8 |
so when a function takes a real as argument I can aswell give it a integer? EDIT: Oh wait just noticed you used a real in the loop : P |
| 05-19-2006, 02:18 PM | #9 |
you can use integers where reals are required. Unless you are in a return value. (Don't ask why) one thing to note though is that some times you need R2I to ensure that real division will be done JASS:local integer a=1 local integer b=3 local real c = a/b //result is 0.00 local real e = I2R(a/b) //result is 0.00 local real d = I2R(a)/b //result is 0.3333333 |
| 05-19-2006, 02:20 PM | #10 |
JASS:local real d = a/R2I(b) //result is 0.00 |
| 05-19-2006, 02:22 PM | #11 |
what? If any of them is a real then it will be real division otherwise it will be integer divisision |
| 05-19-2006, 02:28 PM | #12 |
ok |
