Is it more efficient to use 'Otherwise'
jorkos
Member, PRO Posts: 353
Hey guys, i'm wondering if it is more efficient to use 'Otherwise'. I have an actor that will do something different if a global attribute is either 1,2,3...25
There are 25 different things it will do. Is it more efficient to write 25 rules or should i create one rule and nest everything in 'Otherwise'. Is there a difference?
Thanks
Comments
Otherwise will be more efficient, simply because it will stop checking once it reaches the rule that triggers.
If I have a rule that says:
If attribute is 1 then do A
Else if attribute is 2 then do B
Else if attribute is 3 then do C
Else if attribute is 4 then do D
Else if attribute if 5 then do E
If the attribute is 3, it will have to only go that far down the list of evaluations, and anything below it will be ignored.
If you put them in 5 separate rules, all 5 will be evaluated even if the attribute is
The performance saving will be small, and probably not noticeable. But there should be some. I had to make a project once where I had to compare an attribute to every letter of the alphabet (and some special characters) until it matched one. By nesting the rules and having it evaluate the most commonly used letters first I got a very noticeable performance increase. With 25 possibilities, you might too.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support