December 13, 2003 Re: Switch Statement Optimisation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:brd07g$3l1$1@digitaldaemon.com... > The compiler should be able to sort your cases for you. Although this is made a bit more difficult by fallthrough. But the compiler probably won't be able to tell which cases will be hit most frequently. Yes. There is no reason for the user to do an ordinal sort, that kind of thing compilers are good at. And since the compiler cannot know which are the most frequent case, having the user sort them by most-used-appears-first, works pretty good in practice. |
Copyright © 1999-2021 by the D Language Foundation