Question about "local integer i = GetSpellAbilityId()"

xoxdragonxox

New Member
Reaction score
1
Which would be better to use

JASS:
function DummyFunctionConditions takes nothing returns boolean
    local integer i = GetSpellAbilityId()
    return i=='A03O'
endfunction

function DummyFunction takes nothing returns nothing
    call actions here
endfunction

//===========================================================================
function InitTrig_DummyTrigger takes nothing returns nothing
    set gg_trg_DummyTrigger = CreateTrigger()
    call TriggerAddCondition(gg_trg_DummyTrigger, Condition( function DummyFunctionConditions ) )
    call TriggerAddAction(gg_trg_DummyTrigger,function DummyFunction)
endfunction


Or

JASS:
function DummyFunctionConditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A03O'
endfunction

function DummyFunction takes nothing returns nothing
    call actions here
endfunction

//===========================================================================
function InitTrig_DummyTrigger takes nothing returns nothing
    set gg_trg_DummyTrigger = CreateTrigger()
    call TriggerAddCondition(gg_trg_DummyTrigger, Condition( function DummyFunctionConditions ) )
    call TriggerAddAction(gg_trg_DummyTrigger,function DummyFunction)
endfunction
 

tooltiperror

Super Moderator
Reaction score
231
The first is more standardized, faster, and doesn't declare another variable.
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
@tooltiperror
how come the first is faster? Because of predeclared integer? But I don't think that's a reason....

@xoxdragonxox
you should write this above your code
JASS:
globals
    constant integer ABIL_ID = 'A03O'
endglobals


and then check the i with the ABIL_ID variable
 

luorax

Invasion in Duskwood
Reaction score
67
@tooltiperror
how come the first is faster? Because of predeclared integer? But I don't think that's a reason....

Because he said that it doesn't declare a new variable, he propably meant the second one is faster. It is kinda obvious IMO.
 

tooltiperror

Super Moderator
Reaction score
231
Yeah, second was faster, sorry.

Using [LJASS]GetTriggerUnit[/LJASS] three times in a trigger, for example, is faster than just declaring the variable.
 
Reaction score
456
Yes, but it's very bad practice. Sometimes you should just do what looks better and not give a fuck about speed. Actually, you should always do that.
 

Bribe

vJass errors are legion
Reaction score
67
I always try build my code the easiest way first, then worry about
efficiency later.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top