This is probably an incredibly stupid question.. but at what point should I null handles for max efficiency? I'd like to use my script as a reference.
It seemed natural to me that the handles should be null'ed only once they have been declared - as shown below:
But looking at other people's code I tend to see this:
It seemed natural to me that the handles should be null'ed only once they have been declared - as shown below:
JASS:
function SH_OL_conditions takes nothing returns nothing
local trigger trig
local unit caster
local integer trigid
local integer stats
local effect sfx
if GetSpellAbilityId() == SH_OL_spellid() then
set caster = GetTriggerUnit()
set stats = SH_OL_stats(SH_OL_getlevel(caster))
set sfx = AddSpecialEffectTarget("Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl", caster, "origin")
call SetHeroInt(caster, (GetHeroInt(caster, false)) + stats, true)
call SetHeroAgi(caster, (GetHeroAgi(caster, false)) + stats, true)
set trig = CreateTrigger()
set trigid = GetHandleId (trig)
call TriggerRegisterTimerEvent(trig, 0.2, true)
call SaveTriggerActionHandle(udg_SH_hashtable , trigid, 0, TriggerAddAction(trig, function SH_OL_periodic))
call SaveUnitHandle(udg_SH_hashtable, trigid, 1, caster)
call SaveReal(udg_SH_hashtable, trigid, 2, 0.)
call SaveReal(udg_SH_hashtable, trigid, 3, SH_OL_duration())
call SaveInteger(udg_SH_hashtable, trigid, 4, stats)
call SaveEffectHandle(udg_SH_hashtable, trigid, 5, sfx)
set trig = null
set caster = null
set sfx = null
endif
endfunction
But looking at other people's code I tend to see this:
JASS:
function SH_OL_conditions takes nothing returns nothing
local trigger trig
local unit caster
local integer trigid
local integer stats
local effect sfx
if GetSpellAbilityId() == SH_OL_spellid() then
set caster = GetTriggerUnit()
set stats = SH_OL_stats(SH_OL_getlevel(caster))
set sfx = AddSpecialEffectTarget("Abilities\\Spells\\Orc\\Purge\\PurgeBuffTarget.mdl", caster, "origin")
call SetHeroInt(caster, (GetHeroInt(caster, false)) + stats, true)
call SetHeroAgi(caster, (GetHeroAgi(caster, false)) + stats, true)
set trig = CreateTrigger()
set trigid = GetHandleId (trig)
call TriggerRegisterTimerEvent(trig, 0.2, true)
call SaveTriggerActionHandle(udg_SH_hashtable , trigid, 0, TriggerAddAction(trig, function SH_OL_periodic))
call SaveUnitHandle(udg_SH_hashtable, trigid, 1, caster)
call SaveReal(udg_SH_hashtable, trigid, 2, 0.)
call SaveReal(udg_SH_hashtable, trigid, 3, SH_OL_duration())
call SaveInteger(udg_SH_hashtable, trigid, 4, stats)
call SaveEffectHandle(udg_SH_hashtable, trigid, 5, sfx)
endif
set trig = null
set caster = null
set sfx = null
endfunction