Posts: 1,046
Threads: 29
Joined: Mar 2010
no need for ? and :
pawn Code:
StartRountCount = !StartRountCount;
is "Rount" even a word, or just a typo?
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Code:
StartRountCount = (StartRountCount) ? false : true;
Posts: 1,046
Threads: 29
Joined: Mar 2010
Do you really want something like
pawn Code:
StartRountCount = StartRountCount ? false : true;
this?
My example above
pawn Code:
StartRountCount = !StartRountCount;
is in my opinion much more efficient.
Posts: 1,046
Threads: 29
Joined: Mar 2010
Quote:
Originally Posted by Y_Less
Better question, why? You clearly have code that works, shortening it will not make it "more efficient" (whatever people think that means) and will just make the code harder to read.
|
Have you tested it yet? I had faster results on
than on
pawn Code:
toggle = toggle ? false : true;
to be excact:
Code:
[02:45:40] Starting benchmark test with 3 tests each method with 1000000 loops...
[02:45:40] Toggler - "ternary operator" the 1.
[02:45:40] 1. result of ternary operator toggling: 99 ms
[02:45:40] Toggler - "ternary operator" the 2.
[02:45:41] 2. result of ternary operator toggling: 99 ms
[02:45:41] Toggler - "ternary operator" the 3.
[02:45:41] 3. result of ternary operator toggling: 99 ms
[02:45:41] Toggler - "equals not" the 1.
[02:45:41] 1. result of equals not toggling: 84 ms
[02:45:41] Toggler - "equals not" the 2.
[02:45:41] 2. result of equals not toggling: 84 ms
[02:45:41] Toggler - "equals not" the 3.
[02:45:41] 3. result of equals not toggling: 84 ms
[02:45:41] Benchmark test finished!