Both are correct, but the second is quicker. The first always checks all conditions, the second does not check all conditions. And it's better to write it like this, so as not to confuse with else's affiliation:
Both are correct, but the second is quicker. The first always checks all conditions, the second does not check all conditions. And it's better to write it like this, so as not to confuse with belonging else:
Or put curly braces around the blocks at once.
Thanks for the advice. While I used to strive to write my EA correctly in general, I now focus on its speed. :)
FAQ: It may be easier to skip through swith(), if you don't need to calculate conditions...
In switch the value in case should be int, not always cond_ is int. Frankly speaking, I was interested in the logic itself, which entry is better/faster.
paladin80: In switch the value at case should be int, not always cond_ is int. I was honestly interested in the logic itself, which entry is better/faster.
Separate conditions, with the most frequently used ones at the top
paladin80: In switch the value at case must be int, not always cond_ is int. I was honestly interested in the logic itself, which entry is better/faster.
The second one, but there is a restriction on nesting.
It is better to use case, if there is such a possibility.
Both are correct, but the second is quicker. The first always checks all conditions, the second does not check all conditions. And it's better to write it like this, so as not to confuse with else's affiliation:
Or put curly braces around the blocks at once.
Both are correct, but the second is quicker. The first always checks all conditions, the second does not check all conditions. And it's better to write it like this, so as not to confuse with belonging else:
Or put curly braces around the blocks at once.
Both are correct
Right, now let's speculate about what happens when cond_1, cond_2, cond_3 are not mutually exclusive...
I'm not arguing, the codes give different results in general. But if the conditions don't overlap, the results seem to be the same.
It may be easier to skip through swith(), if you don't need to calculate conditions...
In switch the value at case should be int, not always cond_ is int. I was honestly interested in the logic itself, which entry is better/faster.
In switch the value at case must be int, not always cond_ is int. I was honestly interested in the logic itself, which entry is better/faster.
The second one, but there is a restriction on nesting.
It is better to use case, if there is such a possibility.