Is it possible to avoid many "ors" (||) in conditions causing the same action? - page 9

 
borilunad:
Thank you! I'm going to try those brackets now!
This option reduced me by half a minute. And in general, the time might have increased due to some changes in the algorithm. No time to check thoroughly now, I'll check later and look for it! Thanks!
 
Vinin:

But you have to check all the options you offer. Otherwise you might make a mistake.
I'll be sure to check! I'm the first one interested!
 
PapaYozh:

To keep warnings from cluttering up your eyes, use {}: {}

if (!A && !B && !C && !D) {} //пустой оператор
else Action();


That's like scratching the back of your head with a heel :) Why four extra operations and a superfluous line? Because the original version looked like this:

if (A || B || C || D) Action();
And it's especially amusing that the topicstarter chose your variant out of all offered ))
 
Meat:


It's like scratching the back of my head with a heel :) Why 4 extra operations and an extra line? After all, the original version looked like this:

And it's especially amusing that the topicstarter chose your variant out of all offered ))

I tested all the proposed options, and it turned out that the fastest is this one: if (A || B || C || D) Action();

To reduce the time, I made some conditions, which are needed very rarely, but in another block, and even added one more, but without bool's, which would add time. I continue to dig through everything possible, looking for justified simplifications, so far on demo works stable and without errors. The thread is open, I will surely share something interesting or unclear. Thank you all!

 
borilunad:

I tested all the suggested variants, and it turns out that the fastest is this one: if (A || B || C || D) Action();

I wonder how it could be faster than this: if (A) Action(); else if (B) Action(); else if (C) Action(); else if (D) Action();

 
Meat:

I wonder how it could be faster than this: if (A) Action(); else if (B) Action(); else if (C) Action(); else if (D) Action();

Sorry, Alexey, I just got home! This version does not fit, because, as I explained above, Acron(); is not just an execution function, but contains several more conditions that are common to the previous ones, but different in direction, and, accordingly, in different order of executing the necessary actions. As you understand, I could not make the code heavier with this variant. And in principle I agree with you that your version could be faster, if Action(); was just a call of one function, nothing more. Thank you very much for help in my search of optimal solutions! Good night to you!
 
borilunad:
Sorry, Alexey, just got home! This variant is not suitable, because, as I explained above, Acron(); is not just an execution function, but contains several more conditions, common to the previous ones, but different in direction, and, accordingly, in different order of executing the necessary action functions. As you understand, I could not make the code heavier with this variant. And in principle I agree with you that your version could be faster, if Action(); was just a call of one function, nothing more. Thank you very much for help in my search of optimal solutions! Good night to you!
The result, as one would expect, is from the category: "The shampoo got even more anti-dandruffy!!!"! :)))
 
TarasBY:
The result, as you'd expect, is of the "The shampoo got even more anti-dandruffy!!!" variety. :)))
If you associate dandruff in your hair with bugs in the code, then you should certainly expect, hope, achieve, look for interesting solutions, but not stampede!
 
borilunad:
If you associate dandruff in your hair with bugs in the code, then of course you should expect, hope, achieve, look for interesting solutions, but not stampede!

And you call this process (9 pages long) "finding interesting solutions"? :)))

On the 1st page - it was a help on "help", and after the 2nd page there was an interest - "what's the fastest way". BUT the answer to this question assumes to contain figures (I already did not mention "purity of experiment" - these are conditions that ensure the adequacy of the obtained results)... Otherwise - about "shampooing"! :)))

 
TarasBY:

And you call this process (9 pages long) "finding interesting solutions"? :)))

On the 1st page - it was a help on "help", and after the 2nd page there was an interest - "what's the fastest way". BUT the answer to this question implies to contain figures (I already did not mention "purity of experiment" - these are conditions that ensure the adequacy of the obtained results)... :)))

This question of speed is what moved me to address the esteemed forum members, "how to avoid a lot of "or" ...", as believed that it causes a loss in time. And if some are moved to enter into polemics because of their ambitions, or persistently promote their developments, it remains their personal business, and does not concern me. Anyway, thanks to all who responded! I wish success to everyone!
Reason: