• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

TimerUtils

Status
Not open for further replies.
Level 19
Joined
Dec 12, 2010
Messages
2,074
Is there any reason why this lib is stil a thing?
"pro": instead of creating object you check for the one of pre-created group, which perfomance-wise better.
Reality: any operation in JASS takes ages comparing to engine's workout, and timers are also the most light-weight object of the whole game. Even a single compare will kill all the purpose of this nitpicking, not to speak you also have to return value.

"pro": you can attach a single integer data inside the timer with 1 func.
Reality: you can do that via tons of other stuff, which barely makes any difference, as it's still dirty hack and not perfomance trick.

So what the point?
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
Well it is easier to write
JASS:
//Start
call TimerStart(NewTimerEx(this), 1.0, false, function thistype.onPeriod)
//Retrieve
local thistype this = ReleaseTimer(GetExpiredTimer())

than

JASS:
//Start
set t = CreateTimer()
set thistype.tb[GetHandleId(t)] = this  //Table
call TimerStart(t, 1.0, false, function thistype.onPeriod)
set t = null
//Retrieve
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local thistype this = thistype.tb[id] //Table
call thistype.tb.remove(id)
call DestroyTimer(t)
set t = null

What the point? convenience.
Does it make a difference performance-wise? No, I think it's negligible
Hotel? Trivago
 
  • Like
Reactions: AGD
Status
Not open for further replies.
Top