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:

    “The respect for human rights is one of the most significant advantages of a free and democratic nation in the peaceful struggle for influence, and we should use this good weapon as effectively as possible.”
    —Jimmy Carter (James Earl Carter, Jr.)

    “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)

    “But there are advantages to being elected President. The day after I was elected, I had my high school grades classified Top Secret.”
    —Ronald Reagan (b. 1911)