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:

    If we live in the Nineteenth Century, why should we not enjoy the advantages which the Nineteenth Century offers? Why should our life be in any respect provincial?
    Henry David Thoreau (1817–1862)

    There are great advantages to seeing yourself as an accident created by amateur parents as they practiced. You then have been left in an imperfect state and the rest is up to you. Only the most pitifully inept child requires perfection from parents.
    Frank Pittman (20th century)

    We work harder than ever, and I cannot see the advantages in cooperative living.
    Lydia Arnold, U.S. commune supervisor (of the North American Phalanx, Red Bank, New Jersey, 1843- 1855)