vinsci@nic.funet.fi (Leonard Norrgard) (05/12/91)
If your program executes switch() statements often, be warned that the SAS/C 5.10a code generator generates slow code for this (and its optimizer doesn't help). FSF's GCC (and probably many others) generate a binary search (at least for sparse case-keys), while SAS/C generates a linear search taking N/2 steps on the average to find the correct case entry (where N is the number of case: entries). The binary search takes log2(N) steps. For a switch() with 20 case entries the binary search is about 2 times faster, for bigger switch()es, the speed increase is bigger. We talked about this (and other things) with John Toebes of SAS at the Amiga '90 exhibition in Cologne last November. He said then that binary searches as well as jump table searches would be available in a future version, so I called SAS/C the other day to see if it was "in there" already. Sadly enough, the tech support person I talked to mentioned that it wouldn't be included before SAS/C 6.0 (due out at the end of the year). Before that they only expect to put out a bug fixing patch (expected in July). -- Leonard