• 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.

to ensure the efficiency...

Status
Not open for further replies.
Well, I've some question regarding the efficiency.
I've some problems with spelltriggers.

1) People keep saying that conditions are faster then actions, ok.
2) If I use conditions, all locals for the spell are allocated on each cast, since I can't "write" them after the if condition if it's the right spell.
JASS:
function MyCondition takes nothing returns boolean
    local unit u
    local player p
    local real x
    local real y
    if GetSpellAbilityId() == SPELL_ID then....
Each cast would first allocate them before checking... that's a waste of performance, isn't it?
3) Is it faster with a dummyfunction?
JASS:
function MyConditionEx takes nothing returns nothing
    local unit u
    local player p
    local real x
    local real y...
endfunction

function MyCondition takes nothing returns boolean
    if GetSpellAbilityId() == SPELL_ID then
        call MyConditionEx()...
4) Is a single trigger with ALL spells better (huge if-condition and keep in mind that you could deactivate unnecessary triggers)
JASS:
function MyCondition takes nothing returns boolean
    local integer ABIL_ID = GetSpellAbilityId()
    if ABILD_ID = 'ASDF' then
        call FunctionASDF()
    elseif ABILD_ID = 'SDFG' then
        call FunctionSDFG()...
5) If 4) is true, how fast would a hashtable with the spell-ids be instead of a huge if-condition? (Code-Array with the IDs in a table)

Greets, Justify
 
Level 11
Joined
Apr 29, 2007
Messages
826
1) People keep saying that conditions are faster then actions, ok.
I assume that's because they get evaluated before the actions do.

2) If I use conditions, all locals for the spell are allocated on each cast, since I can't "write" them after the if condition if it's the right spell.
]Each cast would first allocate them before checking... that's a waste of performance, isn't it?
If that few 0.000001 or whatever nanoseconds would really matter.

3) Is it faster with a dummyfunction?
No. Calling functions is way slower than doing your stuff in there.

4) Is a single trigger with ALL spells better (huge if-condition and keep in mind that you could deactivate unnecessary triggers)
In the worst case you'd have to check each if, making it very very slow.

5) If 4) is true, how fast would a hashtable with the spell-ids be instead of a huge if-condition? (Code-Array with the IDs in a table)
Sadly, there are no code-arrays and you also can't store code variable within a hashtable.
 
There are code arrays, due to vexorians imbaness. I only have to store their id.
Well, if you have ~80 Spells in your map and each cast allocates ~5 variables (I think these theoretical values are quite normal) you'd allocate 400 variables on each cast. That can't be very performant.
+, you'd have many trigger evaluations for each cast.
A single trigger would shrink this down to... 1 :)
That's why I'm asking.
 
Status
Not open for further replies.
Top