Introduction to OOP | Chapter 27: Implementation : | next | previous | audio | real | text |
In order to avoid the cost of a dynamic search of dispatch tables, a single global cache can be used to hold frequently invoked methods.
The cache is used as a large hash table.
Prior to searching a dispatch table, the a single hashed entry is examined - if it matches the selector being sought, the method is used, if not the dispatch table is searched and the new entry replaces the value in the hash table.
Assuming a good hash function is used, efficiency can be very high.