- Joined
- Oct 11, 2012
- Messages
- 711
Hi guys, please see the following example:
Which one is better? Thanks.
JASS:
//Are there any practical difference between these two allocation and deallocation methods?
//Which one is better?
//First:
globals
integer array a
integer index = 0
endglobals
static method Loop takes nothing returns nothing
local thistype this
local integer i = 0 //<--------------
loop
exitwhen i > index
set this = a[i]
......
if RemainingTime <= 0 then
set index = index - 1 //<--------------
set a[i] = a[index]
set i = i - 1
....
else
....
endif
......
set i = i + 1
endloop
endmethod
static method Run takes nothing returns nothing
local thistype this = this.allocate
....
set a[index] = this
set index = index + 1 //<--------------
if index == 1 then
call TimerStart(...., function thistype.Loop)
endif
....
endmethod
//Second:
globals
integer array a
integer index = 0
endglobals
static method Loop takes nothing returns nothing
local thistype this
local integer i = 1 // <-------------
loop
exitwhen i > index
set this = a[i]
......
if RemainingTime <= 0 then
set a[i] = a[index]
set index = index - 1 //<--------------
set i = i - 1
....
else
....
endif
......
set i = i + 1
endloop
endmethod
static method Run takes nothing returns nothing
local thistype this = this.allocate
....
set index = index + 1 //<--------------
set a[index] = this
if index == 1 then
call TimerStart(...., function thistype.Loop)
endif
....
endmethod
Which one is better? Thanks.
Last edited: