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:
“When the manipulations of childhood are a little larceny, they may grow and change with the child into qualities useful and admire in the grown-up world. When they are the futile struggle for love and concern and protection, they may become the warped and ruthless machinations of adults who seek in the advantages of power what they could never win as children.”
—Leontine Young (20th century)
“Men hear gladly of the power of blood or race. Every body likes to know that his advantages cannot be attributed to air, soil, sea, or to local wealth, as mines and quarries, nor to laws and traditions, nor to fortune, but to superior brain, as it makes the praise more personal to him.”
—Ralph Waldo Emerson (18031882)
“If the minds of women were enlightened and improved, the domestic circle would be more frequently refreshed by intelligent conversation, a means of edification now deplorably neglected, for want of that cultivation which these intellectual advantages would confer.”
—Sarah M. Grimke (17921873)