View Single Post
Old 10-31-2011, 07:24 PM   #167
Magtheridon96
User
 
Join Date: Feb 2011
Posts: 7

Magtheridon96 has little to show at this moment (0)

Default

ReleaseTimerEx() isn't needed.
ReleaseTimer should return the timer data though.

NewTimerEx() is useful for shortening code:

Collapse JASS:
local thistype this = recycler[0]
local timer t = NewTimer()

if this == 0 then
    set instances = instances + 1
    set this = instances
else
    set recycler[0] = recycler[this]
endif

call SetTimerData(t, this)
call TimerStart(t, 0.5, true, function thistype.run)

set t = null

->

Collapse JASS:
local thistype this = recycler[0]

if this == 0 then
    set instances = instances + 1
    set this = instances
else
    set recycler[0] = recycler[this]
endif

call TimerStart(NewTimerEx(this), 0.5, true, function thistype.run)

Now tell me. Which one of those snippets is better?
See why a NewTimerEx would be useful?
Magtheridon96 is offline   Reply With Quote