Tue, 28 Sep 2010 13:33:16 -0400, bearophile wrote: > Through Reddit I have found a small article about reverse engineering > the switch statement: http://www.codeproject.com/KB/cpp/switch.aspx > > I have compiled a test program with GCC and then with DMD with minimal > changes, this is the D program and the asm from the two compilers: > [snip] > > gcc and llvm-gcc use a binary search, dmd a linear one.
Instead of O(n) linear search or O(ln n) binary search, why not use O(1) jump tables in this case?
