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.

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 mean