Multiway branch

Multiway branch is the change to a program's control flow based upon a value matching a selected criteria.

A multiway branch is often the most efficient method of passing control to one of a set of program labels, especially if an index has been created beforehand from the raw data.

For example, the Has30Days example [presented earlier] can be implemented as the following:[C example]""A Superoptimizer Analysis of Multiway Branch Code Generation" by Roger Anthony Sayle can be replaced, using a "safe-hashing" technique, with - or it can be replaced, using an index mapping table lookup, with - (in view of the simplicity of the latter case, it would be preferable to implement it in-line, since the overhead of using a function call may be greater than the indexed lookup itself.)

Multiway branching is an important programming technique which is all too often replaced by an inefficient sequence of if tests.

Peter Naur recently wrote me that he considers the use of tables to control program flow as a basic idea of computer science that has been nearly forgotten; but he expects it will be ripe for rediscovery any day now.