| 09-12-2007, 03:27 PM | #1 |
I've found this : http://www.wc3jass.com/viewtopic.php...7c696f44ae3f43 PitzerMike had said that : // for speed reasons i don't loop through charmaps here. Ok but what about the many if/then/endif ? If i use only one if/then/endif and many elseif, will it be faster ? |
| 09-12-2007, 03:40 PM | #2 |
My guess is that it would compile to exactly the same bytecode. |
| 09-12-2007, 03:44 PM | #3 | |
Quote:
|
| 09-12-2007, 04:40 PM | #4 |
There is no way to test the speed difference, but I'm 99% sure that there isn't one. |
| 09-12-2007, 04:45 PM | #5 | |
Quote:
|
| 09-12-2007, 06:29 PM | #6 |
No matter what you do, the difference is probably too small to notice. Maybe with stopwatch natives, but even that would probably be inconclusive due to error margins. |
| 09-12-2007, 06:55 PM | #7 |
The difference, if any, is far too small to detect. |
| 09-12-2007, 06:55 PM | #8 |
ok, but at least we win ( i want mean the script will be a few more little) some bytes and it is faster to write ^^ |
| 09-13-2007, 04:04 PM | #9 |
Double post i've found how to test and i can say that using elseif is the best solution. I'm happy to say : PitzerMike improve your code :P By the way, really thx for widgetizer PipeDream for grimoire. Vexorian, for the jassnewgenpack,wc3mapoptimizer and of course Vjass. And in general, all people who improve the war3 modding Ps : i know that an integer becomes negative when you reach the max value, but in this example he had no time for this |
| 09-13-2007, 04:49 PM | #10 |
well, if only strings had a < operator for lexicographical compare it could have been made much faster. I think that gamecache is faster in this case... |
| 09-13-2007, 05:07 PM | #11 | |
Quote:
could you give an exemple plz, i don't uderstand what you said |
| 09-13-2007, 05:10 PM | #12 |
Under the assumption < worked in strings: JASS:if (c<"a") then if (c<"P") then if (c<"D") then if (c<"B") then return 64 else return 65 endif //etc, etc etc. endif Later I said a single GetStoredInteger ought to be faster than 126 string comparisons. Although I forgot about gamecache's lame case insensitivity which will require an extra concatenation or at least native call. |
| 09-13-2007, 05:26 PM | #13 |
Hmm maybe but why not use elseif instead of such many if/then/endif ![]() |
| 09-13-2007, 06:56 PM | #14 |
I was thinking the same, but I realized that elseifs sometimes bugs. I'll take this opportunity to explain this bug that I recently found. If you set a conditional in this way: JASS:function elseiftest takes nothing returns nothing if CondA then // CondA Actions elseif CondB then // CondB Actions elseif CondC then // CondC Actions elseif CondD then // CondD Actions //.... elseif CondN then // CondN Actions endif endfunction If all the conditions before N are false, the CondN is evalueated, it doens't matter if CondN is false. The bad thing is that it happens sometimes, not always, and unfortunately I haven't been able to find the cause of this bug. I'd like to know if this situation has happened to anyone. |
| 09-13-2007, 07:33 PM | #15 |
Post the figures you got from any benchmarking. |
