Re: How are switches optimized

2018-06-02 Thread Dennis via Digitalmars-d-learn
On Friday, 1 June 2018 at 21:18:25 UTC, IntegratedDimensions wrote: If one has a switch of N case then the last cost surely does not cost N times the cost of the first, approximately? It depends on the compiler and optimization level. In general, no optimization or just a handful of cases

Re: How are switches optimized

2018-06-02 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 1 June 2018 at 21:18:25 UTC, IntegratedDimensions wrote: What is the best optimizations that a compiler does to switches in general and in the D compilers? The best possible depends a lot on the specific case at hand. Best possible is to fully elide the switch, which does happen.

How are switches optimized

2018-06-01 Thread IntegratedDimensions via Digitalmars-d-learn
What is the best optimizations that a compiler does to switches in general and in the D compilers? A switch can be seen as if statements, or safer, nested if elses. but surely the cost per case does not grow with depth in the switch? If one has a switch of N case then the last cost surely