On Mon, 29 Apr 2013 13:16:59 -0400, John Gilmore wrote: >The question which is faster depends in detail upon > >1) whether binary search is implemented in assembly language, in which >case ternary comparison operations are available, or in a >statement-level language other that PL/I, in which case ternary >comparisons must be simulated using a binary decision tree, and > I would expect any decent compiler nowadays to optimize that difference away.
>Both are, of course, radically inferior to branch-table based schemes, >e.g., the one used to implement the C switch staterment and the >analogous PL/I select group, that do no searching at all. > Long ago, maintaining the code generation of a compiler for Pascal, which language allows radically sparse CASE statements, I selected whether to use a branch-tree or a branch-table based on the sparseness of the labels. If I selected a branch-tree, it was binary, exploiting the ternary result of the s/370 Compare instruction. Since performance of the branch-table is always better, I made the decision based on (roughly estimated) object code size. There was no option for the programmer. -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN