Branch Table - Advantages

Advantages

Advantages of branch tables include:

  • compact code structure (despite repeated branch opcodes)
  • reduced source statements (versus repetitive If statements)
  • reduced requirement to test return codes individually (if used at call site to determine subsequent program flow)
  • Algorithmic and code efficiency (data need only be encoded once and branch table code is usually compact), and the potential to attain high data compression ratios. For example, when compressing country names to country codes, a string such as "Central African Republic" can be compressed to a single index, resulting in large savings – particularly when the string appears many times. In addition, this same index can be used to access related data in separate tables, reducing storage requirements further.

For library functions, where they may be referenced by an integer:

  • improve compatibility with subsequent software versions. If the code of a function and the address of its entry point is changed, only the branch instruction in the branch table needs to be adjusted, application software compiled against the library, or for the operating system, does not need modification.

In addition, calling functions by number (the index into the table), can sometimes be useful in some cases in normal application programming

Read more about this topic:  Branch Table

Famous quotes containing the word advantages:

    ... is it not clear that to give to such women as desire it and can devote themselves to literary and scientific pursuits all the advantages enjoyed by men of the same class will lessen essentially the number of thoughtless, idle, vain and frivolous women and thus secure the [sic] society the services of those who now hang as dead weight?
    Sarah M. Grimke (1792–1873)

    A woman might claim to retain some of the child’s faculties, although very limited and defused, simply because she has not been encouraged to learn methods of thought and develop a disciplined mind. As long as education remains largely induction ignorance will retain these advantages over learning and it is time that women impudently put them to work.
    Germaine Greer (b. 1939)

    The advantages found in history seem to be of three kinds, as it amuses the fancy, as it improves the understanding, and as it strengthens virtue.
    David Hume (1711–1776)