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

 
borilunad:
This question of speed is what moved me to address the esteemed forum members, "how to avoid a lot of "or" ...", because I believed that it causes a loss of 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! And I wish success to all!
First learn how to work with your brain, you have already learned how to work with your tongue. Good luck!
 
TarasBY:
First learn how to work with your brain, you have already learned how to work with your tongue. Good luck!
It remains to be regretted that your culture, not to mention basic ethics, has not gone far from your historical idol Taras Bulba!
 
As I understand it - there will be no result. Pity. Although it doesn't take long to do (if necessary), there are plenty of options offered
 
Vinin:
From what I understand, there will be no result. Pity. Although it doesn't take long to do (if necessary), there are plenty of options offered

On the previous page I reported the preliminary result to Alexey (Meat) and my explanations, which I now give you in full:

avatar
891
Meat 13.02.2013 20:36
borilunad:

I've tested all suggestions and it turns out the fastest one is: 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();


947
borilunad 13.02.2013 22:46
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 Alexei, 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!
Can't add anything to this yet, as the bool's haven't given a time cut, and I'm currently checking all the functions I use, and, as you can imagine, it takes a lot of time to do so. Thanks for your consideration!
 
Not a problem in principle. I can get the results myself. Numerical results
 
Vinin:
In principle, not a problem. I can get the results myself. Numerical results

Victor, just now I finished cleaning the code, like flats after renovation, I cleaned a lot of rubbish, such as unnecessary conditions, unnecessary normalizations, corrected the logic, reduced the number of used functions. Alexey(alsu) helped me a lot with his advice, and I am grateful to him for that. As the result the 4 month long run in the tester was a bit longer than 2 minutes, and I was satisfied with it. And bool's functions turned out to be unnecessary, because they didn't give me any speed advantage, but they gave me some experience in working with them which will come in handy later.

I thank all who took part and wish success and good profits to everyone!