- Joined
- Feb 11, 2011
- Messages
- 1,860
Hi guys,
I have two burning questions that I want to get out of the way. Here they are;
Question 1:
If I have a small function that returns a damage amount based on a hero's strength like this:
How necessary is it to null the unit variable? It seems as though it would make the function longer:
Question 2:
When destroying struct instances, is it necessary to set each variable with a handle to null before deallocating? For example:
I have always been doing this, but I am curious if
Thanks,
Mr_Bean
I have two burning questions that I want to get out of the way. Here they are;
Question 1:
If I have a small function that returns a damage amount based on a hero's strength like this:
JASS:
private function GetDamage takes unit u returns real
return 6. * GetHeroStr(u, true)
endfunction
How necessary is it to null the unit variable? It seems as though it would make the function longer:
JASS:
private function GetDamage takes unit u returns real
local real str = GetHeroStr(u, true)
set u = null
return 6. * str
endfunction
Question 2:
When destroying struct instances, is it necessary to set each variable with a handle to null before deallocating? For example:
JASS:
private struct Test
unit caster
unit target
private method destroy takes nothing returns nothing
set .caster = null
set .target = null
call .deallocate()
endmethod
private method kill takes nothing returns nothing
call KillUnit(.caster)
call KillUnit(.target)
call .destroy()
endmethod
private static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set .caster = GetTriggerUnit()
set .target = GetSpellTargetUnit()
call .kill()
return this
endmethod
endstruct
I have always been doing this, but I am curious if
.deallocate()
is enough.Thanks,
Mr_Bean