Magentix
if (OP.statement == false) postCount++;
- Reaction score
- 107
Which one would work the fastest and has less lag potential if used intensively (Like: i > 100 or sth)?
3 libraries inside this script:
3 libraries inside this script:
JASS:
// This takes 2 triggers
library TwoSeparates initializer Init
private function A takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 5
// Approx 20 "A" calls in here
set i = i + 1
endloop
endfunction
private function B takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 7
// Approx 20 "B" calls in here
set i = i + 1
endloop
endfunction
//=================================================
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterTimerEvent(T,0.05,true)
call TriggerAddAction(T,function A)
set T = CreateTrigger()
call TriggerRegisterTimerEvent(T,0.05,true)
call TriggerAddAction(T,function B)
endfunction
endlibrary
//=====================================================
//=====================================================
// This takes one trigger but 2 loops, doubling the calls inside one function
library OneYetSeparate initializer Init
private function AB takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 5
// Approx 20 "A" calls in here
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 7
// Approx 20 "B" calls in here
set i = i + 1
endloop
endfunction
//=================================================
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterTimerEvent(T,0.05,true)
call TriggerAddAction(T,function AB)
endfunction
endlibrary
//=====================================================
//=====================================================
// This takes one trigger and 1 loop but executes double the calls in one function as well
library OneTogether initializer Init
private function AB takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 7
if i < 6 then
// Approx 20 "A" calls in here
endif
// Approx 20 "B" calls in here
set i = i + 1
endloop
endfunction
//=================================================
private function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterTimerEvent(T,0.05,true)
call TriggerAddAction(T,function AB)
endfunction
endlibrary