Which variables are better?
I have a trigger, that creates LOTS of local variables every time it runs, and it runs kind a often. So I started wondering if it isn't better just to use some global variables, not to create/destroy the local ones every time the trigger runs.
I have a trigger, that creates LOTS of local variables every time it runs, and it runs kind a often. So I started wondering if it isn't better just to use some global variables, not to create/destroy the local ones every time the trigger runs.
JASS:
local unit m_targ = udg_GDD_DamagedUnit
local unit shooter = udg_GDD_DamageSource
local location m_ut_pt = GetUnitLoc(shooter)
local location m_point = GetUnitLoc(m_targ)
local real x = GetLocationX(m_ut_pt)
local real y = GetLocationY(m_ut_pt)
local unit s_targ
local real health = GetWidgetLife(m_targ)
local timer time = CreateTimer()
local integer id = GetUnitTypeId(shooter)
local integer targets = LoadInteger(udg_Table, id, 'targ')
local integer a_type = LoadInteger(udg_Table, id, 'atyp')
local real range = LoadReal(udg_Table, id, 'rang')
local real dist = LoadReal(udg_Table, id, 'para')
local boolean upg = LoadBoolean(udg_Table, id, 'upgr')
local boolean al_hits_main_tar = LoadBoolean(udg_Table, id, 'ahmt')
local integer missile = LoadInteger(udg_Table, id, 'misl')
local real ofst_ang = LoadReal(udg_Table, id, 'ofst')
local real dam
local real init_ang = AngleBetweenPoints(m_ut_pt, m_point) + ofst_ang
local location para_pt = PolarProjectionBJ(m_ut_pt,dist,init_ang)
local unit dummy = CreateUnitAtLoc(GetOwningPlayer(shooter), 'h00C', m_ut_pt, 0.00)
local real max_hp
local group g
local integer count
local integer d_id = GetHandleId(dummy)
local timer table_clear = CreateTimer()
local integer left_c
local integer right_c
local unit array left
local unit array right
local integer dice